Posts

Showing posts from February, 2013

Transform a spreadsheet into a localization xml file using python

Image
Some time ago a customer at my work provided descriptions of some sort of article codes in the form of a spreadsheet. We needed to transform the information into a localization file in xml format. I don't really remember how I did this at that time. I believe I used some text editor and did some string replacements. I figured it would be a one time thing, so why automate. Now, last week a colleague started working on a new project for this client and it turns out he needs to build again new localization files.

So I figured a script that would automate the transformation would be nice to have, fun to write and good practice.

First we need to export the spreadsheet as a csv file (UTF-8 encoded) and call it input.csv. I use LibreOffice to do this.

We will run the python script csv2loc.py from the same directory as the input file.
This will result in the output.xml file.


Related articlesHow to Open an XML File for DummiesPyspread: the non-traditional spreadsheetHow to use python to parse X…