Skip to content

Commit

Permalink
Merge pull request #22 from BlackEdder/skip_lines2
Browse files Browse the repository at this point in the history
Added optional argument to contains_header to skip multiple header lines
  • Loading branch information
cantino committed Jan 1, 2014
2 parents df7e608 + 1a4e2a5 commit 41fde2c
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit 41fde2c

Please sign in to comment.