How To Convert Large XML Files to CSV


I usually struggle with converting very large XML files to other formats just because they are in a dynamic format and most programs you find run out of memory before properly parsing them.¬†Well, I’m happy to say, I found a FAST and EASY solution. Of course this will work for small files as well as big files.

You’ll want to grab a copy of the msxsl command line utility from Microsoft.

After you’ve got that, you’ll need to setup a XSL file to tell the program how to format your file. If you’re unfamiliar with XSL, you can familiarize yourself here.

After you’ve got your XSL file created, it’s a simple command line entry:

msxsl xml_file.xml xsl_file.xsl -o output_file.csv

The following is a sample XML and XSL file that I used.

XML File:

		Tue, 20 Jan 2009 16:28:08 CST
		Tue, 20 Jan 2009 16:51:01 CST

			The Hills Season 1

		Tue, 20 Jan 2009 16:28:08 CST
		Tue, 20 Jan 2009 16:53:54 CST

			Hogan Knows Best Season 2

		Thu, 22 Jan 2009 14:49:12 CST
		Thu, 22 Jan 2009 14:51:35 CST

			Carlos Mencia 2007

			Comedy Central

XSL File (Creates tab-delimited file)


2 thoughts on “How To Convert Large XML Files to CSV”

  1. msxml is giving me “Not enough storage to complete this operation” for my 600 MB XML file. After a bit more research, it appears most xsl tools have to store the entire document tree in memory, which makes them inappropriate for very large files. I’m going to try using sed.

Leave a Reply

Your email address will not be published. Required fields are marked *