-
Notifications
You must be signed in to change notification settings - Fork 3
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
Specified two-column csv file #78
Conversation
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.
Please see my inline comments.
pyfunnel/pyfunnel.py
Outdated
@@ -89,6 +89,8 @@ | |||
data[s] = dict(x=[], y=[]) | |||
with open(vars(args)[s]) as csvfile: | |||
spamreader = csv.reader(csvfile) | |||
if (len(next(spamreader)) != 2): |
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 believe that if you use next
here, the next iteration on the iterator (for loop below) starts at index 1 and not 0, i.e., the first row is skipped.
Why not test len(spamreader[0])
? Or each line within the for loop: len(row)
?
pyfunnel/pyfunnel.py
Outdated
@@ -89,6 +89,8 @@ | |||
data[s] = dict(x=[], y=[]) | |||
with open(vars(args)[s]) as csvfile: | |||
spamreader = csv.reader(csvfile) | |||
if (len(next(spamreader)) != 2): | |||
raise RuntimeError("The {} CSV file must have exactly two columns.".format(s)) |
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.
Shouldn't this rather be an IOError
?
@AntoineGautier Please see the updated one. |
@JayHuLBL In d067463 I propose to keep the iterable object (rather than casting it into a list which is potentially less memory-efficient) and check the length of each row. My thinking is that, if the CSV is corrupted with, e.g., an element missing at row 10000, the user will have better error information this way. If you want to revert back to checking only the first row, maybe keeping the iterable object and checking |
This closes #76.