csv reader
Jerry Hill
malaclypse2 at gmail.com
Tue Dec 15 16:37:52 EST 2009
On Tue, Dec 15, 2009 at 4:24 PM, Emmanuel <manouchk at gmail.com> wrote:
> I have a problem with csv.reader from the library csv. I'm not able to
> import accentuated caracters. For example, I'm trying to import a
> simple file containing a single word "equação" using the following
> code:
>
> import csv
> arquivoCSV='test'
> a=csv.reader(open(arquivoCSV),delimiter=',')
> tab=[]
> for row in a:
> tab.append(row)
> print tab
>
> As a result, I get:
>
> [['equa\xe7\xe3o']]
>
> How can I solve this problem?
I don't think it is a problem. \xe7 is the character ç encoded in
Windows-1252, which is probably the encoding of your csv file. If you
want to convert that to a unicode string, do something like the
following.
s = 'equa\xe7\xe3o'
uni_s = s.decode('Windows-1252')
print uni_s
--
Jerry
More information about the Python-list
mailing list