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

Foovoid Null foovoid at hotmail.com
Sat Jul 10 21:38:00 CEST 2004

import StringIO

csvReader = csv.reader(StringIO.StringIO("1,2,3,4"))

On 7/10/04 1:21 PM, in article
TkXHc.28545$I%1.27552 at fe1.news.blueyonder.co.uk, "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...
> thanks
> alex

More information about the Python-list mailing list