nanogiants / twineCSV

Converts your twine formatted files to csv and vice versa
MIT License
7 stars 2 forks source link

CSV totwine fails - undefined method `map' for nil:NilClass #6

Open DTown opened 5 years ago

DTown commented 5 years ago

I cannot use the totwine method: twineCSV totwine converted_es.csv twine.txt --trace

It throws this error and trace:

Converting input file converted_es.csv
/usr/local/lib/ruby/gems/2.4.0/gems/twineCSV-1.1.0/lib/twineCSV.rb:68:in `block in to_twine': undefined method `map' for nil:NilClass (NoMethodError)
    from /usr/local/lib/ruby/gems/2.4.0/gems/twineCSV-1.1.0/lib/twineCSV.rb:61:in `each'
    from /usr/local/lib/ruby/gems/2.4.0/gems/twineCSV-1.1.0/lib/twineCSV.rb:61:in `to_twine'
    from /usr/local/lib/ruby/gems/2.4.0/gems/twineCSV-1.1.0/bin/twineCSV:26:in `block (2 levels) in <top (required)>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/commander-4.4.3/lib/commander/command.rb:178:in `call'
    from /usr/local/lib/ruby/gems/2.4.0/gems/commander-4.4.3/lib/commander/command.rb:153:in `run'
    from /usr/local/lib/ruby/gems/2.4.0/gems/commander-4.4.3/lib/commander/runner.rb:446:in `run_active_command'
    from /usr/local/lib/ruby/gems/2.4.0/gems/commander-4.4.3/lib/commander/runner.rb:68:in `run!'
    from /usr/local/lib/ruby/gems/2.4.0/gems/commander-4.4.3/lib/commander/delegates.rb:15:in `run!'
    from /usr/local/lib/ruby/gems/2.4.0/gems/commander-4.4.3/lib/commander/import.rb:5:in `block in <top (required)>'
dasheck0 commented 5 years ago

Can you also provide the source file (i.e. converted_es.csv). This will help to find the problem.

DTown commented 5 years ago

Added the file converted_es.csv.zip

DTown commented 5 years ago

OK, found an unexpected line break. After deleting it it seemed to work. It is a bit strange, because it was exported after editing with LibreOffice.

dasheck0 commented 5 years ago

I can confirm that the unexpected line break causes this and removing it resolves this issue. So that's good. However, the script shouldn't break on such occasions. It should handle them gracefully. I will provide a fix and try to make it more robust.