Click to See Complete Forum and Search --> : Converting CSV to XML File Format


gaby5
July 18th, 2000, 03:11 PM
Hello All,

I have a question about converting a CSV file to XML format how do I do this,

Thanks for any suggestions.

July 18th, 2000, 04:18 PM
There is a MSXml component in VB6.

Lothar Haensler
July 19th, 2000, 01:49 AM
use the excellent example from
http://www.inquiry.com/techtips/xml_pro/10min/10min1099/10min1099.asp

Lothar Haensler
July 19th, 2000, 03:35 AM
if you are familiar with the sed utility (a UNIX tool that's also available for Win32 from www.gnu.org), you can write a converter in a few lines:

1i\
<?xml version="1.0"?>
1i\
<rows>
i\
<row>
s/\(.*\)/\1;/
s@\([^;]+\);@<column>\1</column>@gp
i\
</row>
$a\
</rows>




call this from a DOS commandline (or from vB via shell) like this:
sed -nf yourscriptfile yourinputfile>outputfile.xml

it creates a <row> tag for each row in the CSV file and a <col> tag for each column and all the required tags, so that you can view the result in IE 5.