New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_csv blank lines #680

Closed
hbeale opened this Issue May 21, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@hbeale

hbeale commented May 21, 2017

If there are blank lines before a header, the header is recognized as such but also included as a row. I came across this in read_tsv, but the min example was easier in read_csv.

e.g.

read_csv("\n\nfileName,variableName,fileDescription\nmy.tsv,awesomeStuff,that awesome stuff i made")
# A tibble: 2 × 3
fileName variableName fileDescription
<chr> <chr> <chr>
1 fileName variableName fileDescription
2 my.tsv awesomeStuff that awesome stuff i made

It may not be an additional problem, but in my case I'm also using comments:
read_csv("# this is a comment\n\nfileName,variableName,fileDescription\nmy.tsv,awesomeStuff,that awesome stuff i made", comment="#")

@slonik-az

This comment has been minimized.

slonik-az commented Nov 18, 2017

I ran into this problem today. Very annoying behavior. read.csv has blank.lines.skip parameter. read_csv should have something similar.

@jimhester

This comment has been minimized.

Member

jimhester commented Dec 11, 2017

If you know the number of blank / comment lines use the skip parameter.

@jimhester

This comment has been minimized.

Member

jimhester commented Dec 11, 2017

Closed by 6517708

@jimhester jimhester closed this Dec 11, 2017

@slonik-az

This comment has been minimized.

slonik-az commented Dec 14, 2017

  • It is very dangerous and bug-prone to rely on knowing number of blank lines. I would not let such code through a code review.
  • Empty lines can happen in the middle of the cvs file. In this case skip lines parameter is useless.

I still cannot get it -- why is it so difficult to skip over blank lines. What am I missing?

--Leo

@lock

This comment has been minimized.

lock bot commented Sep 25, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.