[racket] more liberal CSV parsing?

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Fri Jul 30 21:53:40 EDT 2010

Neil's superb CSV reader seems to unfortunately conflict with the
notion of CSV on the OS that maybe loves CSV the most: Windows.  I
spent a while tracking down a CSV reader failure, and was able to
isolate it to the program below:

#lang racket
(require (planet neil/csv:1:6/csv))
((make-csv-reader "\"x\" a"))

Output (error):

[csv-reader] : Erroneous CSV format: Junk after close of quoted field: #\/

In other words, Windows sometimes produces CSV that looks like this:

  d1,d2,"foo" bar,d3

It appears that Neil's reader (undoubtedly rightly) barfs on text
beyond the closing quote and space.

Do one of the options in the library parameterize against this
behavior?  It doesn't appear so....  And sadly, I certainly have no
hope of changing Windows. (-:

-----

Neil, if you want a concrete context, try the output of

  wmic process get commandline /format:csv

on Windows 7.  You get lines like

ROUBAIX,"C:\Program Files\Windows Sidebar\sidebar.exe" /autoRun,2940
ROUBAIX,"C:\Users\sk\Local Settings\Apps\F.lux\flux.exe" /noshow,3048

Mmph: it looks like the output may be just plain broken.  I see
another line that looks like

ROUBAIX,cthelper 49170 xterm :erase=^?:size=24,80,4064

which looks like it has one field too many....

Shriram


Posted on the users mailing list.