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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/reckon/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ def parse
end

@csv_data = csv_engine.parse data.strip, :col_sep => options[:csv_separator] || ','
csv_data.shift if options[:contains_header]
if options[:contains_header]
options[:contains_header].times { csv_data.shift }
end
csv_data
end

Expand Down Expand Up @@ -403,8 +405,9 @@ def self.parse_opts(args = ARGV)
options[:ignore_columns] = ignore.split(",").map { |i| i.to_i }
end

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] = 1
options[:contains_header] = contains_header.to_i if contains_header
end

opts.on("", "--csv-separator ','", "Separator for parsing the CSV - default is comma.") do |csv_separator|
Expand Down