That's great, but it seems like a lot of work just to read in
everything. Take a look at the sample that I did with the
interpreter...

First, X is a simulated input line...
---
x = "
param1,param2,param3,param4,param5,param6,param7,param8,param9,comments
blah , blah, test"
---
Ok, so just like your first example, with commas in the comments.
Next, let's parse that into the variables and seperate on the commas...
without using the CSV module..
---
param1, param2, param3, param4, param5, param6, param7, param8, param9,
comments = x.split(',',9)
---
Simply, this splits on the commas, up to 9 times. So, no need to fix
your input text. Now, the output...
---
f.write(param1 + " " + param2 + " " + param3 + " " + param4 + " " +
param5 + " " + param6 + " " + param7 + " " + param8 + " " + param9 + "
" + "\"" comments + "\"" + "\n")
---
Writes the file, no commas except in the comments, and the comments are
enclosed in quote marks. Also, the line ends in a CR+LF (depending on
O/S).

Is that something similar to what you were looking for? It doesnt look
like your file is properly formatted for CSV, hence I suggest not using
the CSV module. If you want to make your file CSV compatible, it should
have quotation marks around the comments, as they could include commas.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to