Converting CSV to XML

14/07/2011 17:16

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.



I came across the excelent CSV2XML software at Sourceforge: 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):


  1. Open the Visual Studio 2010 Command Prompt window.
  2. Click the Start button, then point to All Programs, Microsoft Visual Studio 2010, Visual Studio Tools, and click Visual Studio 2010 Command Prompt.
  3. 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.:

    return 0;


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







Search site


Alexander Roberts