Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Import-Csv does not handle newlines containing just \r (Carriage Return) #3692

Copy link
Copy link
@Szeraax

Description

@Szeraax
Issue body actions

Steps to reproduce

"one,two,three`rthree,three,three" | out-file test.csv
import-csv test.csv

Expected behavior

Expected result:

one   two   three
---   ---   -----
three three three

Actual behavior

import-csv : The member "three" is already present.

Environment data

Tested on windows 8.1 and windows X (10).

Name                           Value
----                           -----
PSVersion                      5.1.14393.206
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.206
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Steps to fix

It seems that the ImportCsvHelper method located in my C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Utility\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Utility.dll is the culprit.

It looks like the code here:

		private bool IsNewLine(char ch)
		{
			bool result = false;
			if (ch == '\n')
			{
				result = true;
			}
			else if (ch == '\r' && this.PeekNextChar('\n'))
			{
				result = true;
			}
			return result;
		}

should include

			else if (ch == '\r')
			{
				result = true;
			}

and then all will be happy. Thanks!

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.