8000 Add support LF newlines in Import-Csv by iSazonov · Pull Request #5363 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@iSazonov
Copy link
Collaborator
@iSazonov iSazonov commented Nov 7, 2017

Fix #3692.

Fix description

After the fix Import-Csv support CR (\r), LF (\n), CRLF (\r\n) as line delimiters.

@markekraus
Copy link
Contributor

@iSazonov are there existing test cases for all three line ending scenarios?

@iSazonov
Copy link
Collaborator Author
iSazonov commented Nov 7, 2017

Yes, I added new test. Oops... lost commit.

return ch == '\r' || ch == '\n';
}

private
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We
should
fix
this.

But thanks for being consistent. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a good project wide reformatting done right after release? So many times I'm just following the ugly formatting around the code and then have to point that out in reviews as to why my code looks weird or doesn't follow the conventions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the Roslyn code format tool on the code base before we went public - it didn't fix stuff like this, but we should run it again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just after RTM take two formatting weeks to push as many formatting PRs as we can starting with Roslyn code format tool and continue with manual formatting.

{
ReadChar();
}
SkipNewLine();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are two newlines, won't this skip the second?

A better pattern might be to change IsNewLine to return a string ("\n", "\r", or "\r\n") or null, and if the newline must be appended, append the result. There should be no need for SkipNewLine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about skipping empty lines. Formally RFC4180 don't allow empty lines. Although practically it may make sense.

I thought about the pattern ( IsNewLine to return a string ) and decided to begin with SkipNewLine() as seems more readable. Now I'm going to implement IsNewLine(out newLine).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I test with Windows PowerShell - we keep its behaviour and 8000 ignore empty lines.

Microsoft Excel imports empty lines as empty rows. We should discuss this in new Issue if we want because it is a breaking change.

@daxian-dbw daxian-dbw merged commit c86f243 into PowerShell:master Nov 10, 2017
@iSazonov iSazonov deleted the handle-newlines-import-csv branch November 11, 2017 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants

0