csv - how to parse a string, not a file?

Alex Hunsley lard at tardis.ed.ac.molar.uk
Mon Jul 12 06:04:07 EDT 2004


John Lenton wrote:

> On Sat, 10 Jul 2004 19:50:25 GMT, Alex Hunsley
> <lard at tardis.ed.ac.molar.uk> wrote:
> 
>>John Lenton wrote:
>>
>>
>>>On Sat, 10 Jul 2004 19:21:23 GMT, Alex Hunsley
>>><lard at tardis.ed.ac.molar.uk> wrote:
>>>
>>>
>>>>I've using the csv module to parse a string, not a file.
>>>>So how do I make a string look like a file so I can call csv.reader()
>>>>with it?
>>>>
>>>>An an example, I'd like to call something like:
>>>>
>>>>csvReader = csv.reader("1,2,3,4")
>>>>
>>>>.. but this direct attempt won't work as it expects a file or a handle...
>>>
>>>
>>>what is cStringIO?
>>>
>>
>>I'm not sure, but if you google there are answers:
>>
>>http://www.google.com/search?hl=en&ie=UTF-8&q=cStringIO&btnG=Google+Search
> 
> 
> sorry; I should stop giving answers as questions.

Oh, that was an answer! Sorry! I thought you were a newbie who had tried to 
post a new topic but had just hit 'reply' or something like that...







More information about the Python-list mailing list