Skip to content

Commit

Permalink
Updates to allow the csv parser to ignore blank lines
Browse files Browse the repository at this point in the history
  • Loading branch information
McClain Looney committed Sep 15, 2021
1 parent 403f8d9 commit a7e73d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/zizia/parsers/csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def records
file.rewind

CSV.parse(file.read, headers: true).each do |row|
yield InputRecord.from(metadata: row)
yield InputRecord.from(metadata: row) if row.detect { |x| !x.last.nil? }
end
rescue CSV::MalformedCSVError => e
Rails.logger.error "[zizia] The file #{file} could not be parsed as CSV: #{e}"
Expand Down
1 change: 1 addition & 0 deletions spec/zizia/csv_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<<-EOS
title,description,date created
The Moomins and the Great Flood,"The Moomins and the Great Flood (Swedish: Småtrollen och den stora översvämningen, literally The Little Trolls and the Great Flood) is a book written by Finnish author Tove Jansson in 1945, during the end of World War II. It was the first book to star the Moomins, but is often seen as a prelude to the main Moomin books, as most of the main characters are introduced in the next book.",1945
Comet in Moominland,"Comet in Moominland is the second in Tove Jansson's series of Moomin books. Published in 1946, it marks the first appearance of several main characters, like Snufkin and the Snork Maiden.",1946
EOS
end
Expand Down

0 comments on commit a7e73d1

Please sign in to comment.