Skip to content
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

Added optional argument to contains_header to skip multiple header lines #22

Merged
merged 2 commits into from
Jan 1, 2014

Conversation

BlackEdder
Copy link
Collaborator

Some banks add initial lines to the csv file with for example your
starting balance. This option allows one to skip these lines

This patch supersedes pull request #21

Some banks add initial lines to the csv file with for example your
starting balance. This option allows one to skip these lines
opts.on("", "--contains-header", "The first row of the CSV is a header and should be skipped") do |contains_header|
options[:contains_header] = contains_header
opts.on("", "--contains-header [N]", "The first row of the CSV is a header and should be skipped. Optionally add the number of rows to skip.") do |contains_header|
options[:contains_header] = contains_header.to_i || 1
Copy link
Owner

Choose a reason for hiding this comment

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

I think this might always be 0 if N isn't provided because nil.to_i is 0 and 0 || 1 is 0. Did you try it?

Copy link
Owner

Choose a reason for hiding this comment

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

Also, did you try it and see that, if --contains-header is skipped, it does nothing, if --contains-header is included, it does 1, and if --contains-header N is included, it does N? Just sanity checking! :)

@cantino
Copy link
Owner

cantino commented Jan 1, 2014

Thanks @BlackEdder!

@BlackEdder
Copy link
Collaborator Author

You were right. nil.to_i indeed solves to 0. I now tested all three cases (not provided, provided without argument and provided with argument) to check if they worked correctly and they did.

Sorry about not checking properly before :( (I thought I had, but added the to_i after checking the first two options and then didn't recheck).

@cantino
Copy link
Owner

cantino commented Jan 1, 2014

That's why we code review :) Thanks for your contribution!

cantino added a commit that referenced this pull request Jan 1, 2014
Added optional argument to contains_header to skip multiple header lines
@cantino cantino merged commit 41fde2c into cantino:master Jan 1, 2014
@BlackEdder BlackEdder deleted the skip_lines2 branch January 17, 2014 07:11
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.

2 participants