DBD::CSV - how to I coax it to read BOM prefixed files?by ELISHEVA (Prior)
|on May 28, 2017 at 21:06 UTC
ELISHEVA has asked for the wisdom of the Perl Monks concerning the following question:
I have a bom prefixed file that I'd like DBD::CVS (v. 0.49) to read and query, but when I tried I kept getting the error message Execution ERROR: Missing first row due to EIF - Loose unescaped quote . But there are no unquoted fields and the only thing I can think is happening is that it sees the BOM and thinks the first field of the first row begins without a quote. (For those not familiar with the DBD::CSV documentation "Loose unescaped quotes" are quotes embedded in a field that begins without a quote).
I'm fairly certain the problem is the BOM because if I remove the BOM, the file can be read and loaded without error
What's puzzling is that the underlying Text::CSV_XS module is BOM friendly. I've tried a variety of things to no avail, among them:
I had considered just removing the BOM and ignoring the problem, but this isn't a one-off. A data source I don't control is producing these BOM prefixed files. I'd rather not be manually munging files (even with a script), every few months. Furthermore the source, or one of them, is the OECD. They produce a lot of data and I'd like that data to be accessible to other Perl programmers in CSV format, either through the solutions we discuss on this thread or because DBD::CSV has been enhanced to be BOM friendly.
Many thanks in advance