-
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
77f6255
updated readme and added error message for multi-column csv files
JayHuLBL 7c9bbc0
updated library
JayHuLBL 47ba43e
corrected typo
JayHuLBL 64cda69
Update readme and help, check for exactly 2 columns
AntoineGautier 27d7fd1
changed error check and type
JayHuLBL 236d10b
reverted back the length check
JayHuLBL 43df271
make list of the csv reader object
JayHuLBL 857ddda
Keep iterable object and check each row
AntoineGautier f6dddb8
Resolve merge conflict
AntoineGautier d067463
Improve error message
AntoineGautier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
parser = argparse.ArgumentParser( | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description=( | ||
'Run funnel binary from terminal.\n\n' | ||
'Run funnel binary from terminal on two two-column CSV files.\n\n' | ||
'Output `errors.csv`, `lowerBound.csv`, `upperBound.csv`, `reference.csv`, `test.csv` ' | ||
'into the output directory (`./results` by default).'), | ||
epilog='Full documentation at https://github.com/lbl-srg/funnel' | ||
|
@@ -31,12 +31,12 @@ | |
|
||
required_named.add_argument( | ||
"--reference", | ||
help="Path of CSV file with reference data", | ||
help="Path of two-column CSV file with reference data", | ||
required=True | ||
) | ||
required_named.add_argument( | ||
"--test", | ||
help="Path of CSV file with test data", | ||
help="Path of two-column CSV file with test data", | ||
required=True | ||
) | ||
parser.add_argument( | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this rather be an |
||
for row in spamreader: | ||
try: | ||
data[s]['x'].append(float(row[0])) | ||
|
Oops, something went wrong.
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.
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)
?