GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add support LF newlines in Import-Csv by iSazonov · Pull Request #5363 · PowerShell/PowerShell

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Nov 7, 2017

Copy link
Copy Markdown
Collaborator

Fix #3692.

Fix description

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov
Add support LF newlines in Import-CSV
640cc0d
@iSazonov
Ilya (iSazonov) requested review from James Truher (JamesWTruher), Paul Higinbotham (PaulHigin) and Dan Travison (dantraMSFT) as code owners November 7, 2017 12:41
@iSazonov Ilya (iSazonov) assigned Dongbo Wang (daxian-dbw) Nov 7, 2017
@markekraus

Mark Kraus (markekraus) commented Nov 7, 2017

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Nov 7, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

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

markekraus reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Add test.
826adcd
lzybkr
Jason Shirk (lzybkr) reviewed Nov 7, 2017
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs Outdated
return ch == '\r' || ch == '\n';
}

private

@lzybkr Jason Shirk (lzybkr) Nov 7, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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. :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iSazonov reacted with laugh emoji
All reactions
  • 😄 1 reaction

@markekraus Mark Kraus (markekraus) Nov 7, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@lzybkr Jason Shirk (lzybkr) Nov 7, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Nov 7, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lzybkr
Jason Shirk (lzybkr) reviewed Nov 7, 2017
View reviewed changes
Comment thread src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs Outdated
{
ReadChar();
}
SkipNewLine();

@lzybkr Jason Shirk (lzybkr) Nov 7, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Nov 7, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Nov 8, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

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 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ilya (iSazonov) added 2 commits November 8, 2017 08:29
@iSazonov
Implement IsNewLine(ch, out string newLine)
d0482a7
@iSazonov
Fix newline inside quote
19858c2
lzybkr
Jason Shirk (lzybkr) approved these changes Nov 9, 2017
View reviewed changes
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit c86f243 into PowerShell:master Nov 10, 2017
@iSazonov
Ilya (iSazonov) deleted the handle-newlines-import-csv branch November 11, 2017 09:09
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@iSazonov @daxian-dbw
Make Import-Csv support CR, LF and CRLF as line delimiters (PowerShel…
30f5e2f
…l#5363)

With the fix, `Import-Csv` support CR (\r), LF (\n), CRLF (\r\n) as line delimiters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@dantraMSFT Dan Travison (dantraMSFT) Awaiting requested review from dantraMSFT
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
@PaulHigin Paul Higinbotham (PaulHigin) Awaiting requested review from PaulHigin
2 more reviewers
@markekraus Mark Kraus (markekraus) markekraus left review comments
@lzybkr Jason Shirk (lzybkr) lzybkr approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@iSazonov @markekraus @lzybkr @daxian-dbw
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.