8000 Import-Csv does not handle newlines containing just \r (Carriage Return) · Issue #3692 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
Import-Csv does not handle newlines containing just \r (Carriage Return) #3692
@Szeraax

Description

@Szeraax

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!

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0