CSV import considerations

Dirk Hohndel dirk at hohndel.org
Tue Sep 17 04:28:34 UTC 2013


On Tue, 2013-09-17 at 08:55 +0300, Miika Turkia wrote:
> 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

Well, it should be easy enough to recognize a CSV file. Once you have
that, you can simply add the tags in the memory buffer and hand the
modified buffer over to XSLT1, right?

> 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
> 
I have trouble enough with marble (still not solved), I don't want to
add another ill-supported dependency if I can avoid it...
> 
> 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).

No other scripting language dependency, please.

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

What about my suggestion above?

/D




More information about the subsurface mailing list