[GRASS-user] fix for .csv files containg quoted strings and Earthquake demos

Hamish hamish_b at yahoo.com
Sun Jun 17 18:35:08 PDT 2012


Hi,

It seems after some years the USGS has stopped shipping their
.csv earthquake bulletin file, and replaced it with a similar-
but-different file format.

I've updated the batch/cron job demo on the screenshots page,
  http://grass.osgeo.org/screenshots/web.php
but not the PHP demo there (I'm no PHP expert), although I have
moved a copy of the source files into svn,
  http://trac.osgeo.org/grass/browser/grass-promo/tutorials/batch_processing/earthquakes/php_demo/
(@MarkusN: see the batch job script in the parent dir for hints
on parsing the new file format)



Anyway, the new data format contains a couple of columns in the
.csv file which are "quoted, containing commas". Since that is
problematic for v.in.ascii, and is a harder-than-it-might-appear
task to add into the module (in a robust way), I've written small
perl script that translates them into a less troublesome form:
comma separators are converted to pipes (|), commas in quoted
strings are preserved, and "quotes" are removed where it is
appropriate to do so.  You don't need to be in GRASS to run it.

csv_dequote.pl:
  http://grass.osgeo.org/wiki/GRASS_AddOns#Miscellaneous_Add-ons

I didn't put in UTF8 support, but if anyone needs to add that
it's probably just a 1-2 line modification as the Text::CSV perl
module (which does the heavy lifting) supports it.


Hamish


More information about the grass-user mailing list