If you are using Python 2.3 or later, then it has a CSV module included in the standard library. This includes reader objects to take a string in CSV format and convert it to a list of strings, and writer objects to take a list of strings and convert it to a line in a CSV file. So your code could be something like: