CSV: undefined method `encode' for nil:NilClass
If you are importing a legacy database through a CSV file (such as from a Microsoft Excel export) you may bump into this Exception.
It got me scratching my head until I realized that ::CSV
was trying to tell me that my CSV header line had one column less than the data beneath it (and I was asking for header conversion).
Especially hard to see when the missing column header is the last one! In which case it was a simple matter of adding a ;
to mark the missing, unused column.
Written by Arnaud Meuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#