From a7e73d138802c7714927d34d3826465c5fc5524e Mon Sep 17 00:00:00 2001 From: McClain Looney Date: Wed, 15 Sep 2021 14:01:41 -0500 Subject: [PATCH] Updates to allow the csv parser to ignore blank lines --- lib/zizia/parsers/csv_parser.rb | 2 +- spec/zizia/csv_parser_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/zizia/parsers/csv_parser.rb b/lib/zizia/parsers/csv_parser.rb index 5d9661f..dee0244 100644 --- a/lib/zizia/parsers/csv_parser.rb +++ b/lib/zizia/parsers/csv_parser.rb @@ -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}" diff --git a/spec/zizia/csv_parser_spec.rb b/spec/zizia/csv_parser_spec.rb index 9e09d06..9820ef4 100644 --- a/spec/zizia/csv_parser_spec.rb +++ b/spec/zizia/csv_parser_spec.rb @@ -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