1

I am using fastercsv with no pain in my Rails application to parse users uploaded csv files. But recently, one user has uploaded a csv file that throw FasterCSV::MalformedCSVError.

The weird part is that when I open his csv file by openoffice and resave it without any change. Surprise; the resaved csv is working without the malformed error.

I have checked the resaved file and differences between it and original file and found openoffice changed its contents in some cells.

For example,

Original having cell value: "Mahmoud"

But resaved having value : Mahmoud without double quotes

I can't find all differences because this file is more than 6000 lines

Any idea why this may happen? Or can I just resave the csv files by offenoffice lib (not manually) and then use fastercsv?

Mahmoud Khaled
  • 6,226
  • 6
  • 37
  • 42

1 Answers1

0

CSV has many specifications which may not be compatible. Running a headless OpenOffice to sanitize the data would be the safe solution.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265