csv-diff icon indicating copy to clipboard operation
csv-diff copied to clipboard

error occurs when there is the null field

Open maeken2010 opened this issue 8 years ago • 1 comments
trafficstars

Hi

I'm using this tool for some csv files. then, I discover that error occurs when there is the null field. For example, if specifying these csv files, occurs NoMethodError.

a.csv

ID,description,
1,hoge,
2,huga,
3,poyo,

b.csv

ID,description
1,hoge
2,huge
3,piyo
diff = CSVDiff.new("a.csv", "b.csv")
NoMethodError: undefined method `upcase' for nil:NilClass

I think, to need rename fild nil to "NULL" in CSVSource. But, I dont think it's the best solution.

maeken2010 avatar Sep 13 '17 09:09 maeken2010

I have the same issue (using https://github.com/agardiner/csv-diff-report as the front-end):

/home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-0.3.3/lib/csv-diff/csv_diff.rb:154:in `block in get_diff_fields': undefined method `upcase' for nil:NilClass (NoMethodError)
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-0.3.3/lib/csv-diff/csv_diff.rb:154:in `reject'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-0.3.3/lib/csv-diff/csv_diff.rb:154:in `get_diff_fields'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-0.3.3/lib/csv-diff/csv_diff.rb:89:in `initialize'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-report-0.3.4/lib/csv-diff-report/report.rb:221:in `new'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-report-0.3.4/lib/csv-diff-report/report.rb:221:in `diff_file'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-report-0.3.4/lib/csv-diff-report/report.rb:87:in `diff'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-report-0.3.4/lib/csv-diff-report/cli.rb:131:in `process'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-report-0.3.4/lib/csv-diff-report/cli.rb:101:in `run'
        from /home/lr/.rvm/gems/ruby-2.4.1/gems/csv-diff-report-0.3.4/bin/csvdiff:7:in `<top (required)>'
        from /home/lr/.rvm/gems/ruby-2.4.1/bin/csvdiff:23:in `load'
        from /home/lr/.rvm/gems/ruby-2.4.1/bin/csvdiff:23:in `<main>'
        from /home/lr/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
        from /home/lr/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'

0x53A avatar Dec 21 '17 13:12 0x53A