2

I have an issue, when trying to process a csv file, using SmarterCSV. The error I get is -

CSV::MalformedCSVError: Illegal quoting in line 1

This is where the code I use to process the csv file

SmarterCSV.process(file_path)

I have gone through similar questions. But no where I find a good fit that could help me.

I tried to resolve it using some options of SmarterCSV such as -

:remove_empty_values, :remove_empty_hashes etc. But in vain.

I welcome the suggestions or refactoring to make this work? Thanks all

1 Answers1

3

This is due to illegal Unicode characters inside your file.

You can process file with Unicode characters with

f = File.open(file_path, "r:bom|utf-8"); data = SmarterCSV.process(f); f.close

here data will contain parsed data.

Also refer official documentation on this:https://github.com/tilo/smarter_csv#notes-about-file-encodings

eshaiju
  • 753
  • 5
  • 16