CSV import considerations

Miika Turkia miika.turkia at gmail.com
Mon Sep 16 22:55:41 UTC 2013


We have had some requests for importing CSV formatted dive logs and
therefor I have done some reading on the possibility of converting them
with our current import framework (XSL transformations). So far I have only
read about parsing CSV with XSLT and have done no testing whatsoever.

It seems that with XSLT1 (what we use currently) it might be possible to
read CSV files only if the file is modified to include XML tags around the
CSV part. This path does sound quite a kludge since we would need to hack
the input file first to include XML tags and then parse it with XSLT. And
that transformation is not really supported in XSLT1, even though it seems
that it might be possible.
http://stackoverflow.com/questions/8119779/how-to-write-a-csv-parser-using-xslt-1-0

XSLT2 does support reading in "raw" files and should be able to parse them
to XML. Drawback in XSLT2 is that it is not well supported so it seems like
a no-go.
http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html
http://rosettacode.org/wiki/Csv-to-xml.xslt

Parsing the CSV in C is doable but of course scripting languages like perl
or python are a lot more flexible when it comes to parsing strings and
outputting XML. But then again these script languages are not universal,
especially one cannot assume them to be available on Windows (even though
they can be installed there).

Does anyone else have an insight on a solution that would fit us? Or any
other comments on the ones I listed here?

miika
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130917/6e7804ec/attachment.html>


More information about the subsurface mailing list