Converting CSV to XML
I've recently been working with a diverse range of data that arrived on my desk in mainly 2 formats, CSV and XML. For various reasons linked with our in-house Research Information System (RIS) I've had to either convert CSV to XML or vice versa, and so have been on the look out for tools to help with the tasks.
CSV to XML
I came across the excelent CSV2XML software at Sourceforge: https://csv2xml.sourceforge.net/ to help with this one.
I run a Windows box so I had to compile the c++ file for windows using the following method (you need Visual Studio for this):
- Open the Visual Studio 2010 Command Prompt window.
- Click the Start button, then point to All Programs, Microsoft Visual Studio 2010, Visual Studio Tools, and click Visual Studio 2010 Command Prompt.
- Run the following command
cl /EHsc csv2xml.cpp
This produced an error the first time bitching about line 42 'warn' must produce a value, or something like that, so I added the following just below the content at line 42 which seemed to fix the error and it compiled fine after that.:
I then had an .exe to work with from the console.
I then went on to use the XML as a schema for automatically creating Microsft InfoPath forms without the hassle of having to type in all the values for form elements.
This XML technology could really catch on... ;)
I just fed the CSV file I needed to convert into the program using the following command:
csv2xml < test.csv > test.xml
and Hey Presto! the XML file appeared in the same directory
a.l.roberts at swansea.ac.uk