On 10/10/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > > Instead of passing the file object directly to the csv parser, pass in a > generator that reads from the file and explicitly encodes the strings > into UTF-8, along these lines: > > def encode_to_utf8(f): > for line in f: > yield line.encode("utf-8") > > There may be a fundamental problem with this approach that I can't > foresee at the moment, but it's worth a try when your alternative is to > build a Unicode-aware CSV parser from scratch. > > Hope this helps,
I did the following: ##################################################################### def encode_utf8( f ): for line in f: yield line.encode( "utf-8" ) ##################################################################### def BeginLocalizationParsing( outputDir, inputRoot, inputFile ): f = codecs.open( inputFile, "rb", encoding="utf-16" ) r = csv.reader( encode_utf8( f ) ) print r.next() ##################################################################### It worked perfectly! Thank you! I guess I don't have to make a CSV parser after all :P
-- http://mail.python.org/mailman/listinfo/python-list