Hi Julian,

Thanks for your information.

I am trying to upload a CSV file which contains some special
characters (Unicode characters which are not in the ASCII range). The
following is the data which the CSV file contains:

Name              Address                       City
Country                         State           Zip Cde Region
à á â   5334           Swenson Avenue   New York        United States of America
California      12345   North America


I am using the following Code for reading the data from HTML and
process the data in CSV file:

HTML page:
<input type='file' name="file1" id="idfileupload” />

Myfile.py:
csv_file = self.request.get('file1')
csv_reader = unicode_csv_reader(csv_file)
fileReader=csv.reader(csv_file.split("\r
\n"),skipinitialspace=True,quotechar='"',quoting=csv.QUOTE_MINIMAL)
for reader in fileReader:
for read in reader:
        r = read.strip()
        r  = unicode(r, 'utf-8')
        <process the data>

Now, when I try to upload the file, I am getting the following error:”

“ UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position
0: ordinal not in range(128) “

What I understood is, After reading the data from CSV file, I am
getting a 2 byte string in variable "read" in the above code. and as
per my understanding we cannot convert 2 bytes string to unicode so it
is giving the above error

I also tried, decode() and encode() methods. I am getting the same
error.

Please help me out, to read the data from CSV file and convert that to
Unicode and upload in the database?

Looking forward to hear from you

Regards
Prakhil

On Jul 1, 6:15 am, Julian Namaro <[email protected]> wrote:
> Python2.5 supportsunicodeand GAE uses it pretty much everywhere
> already. I'd say you just have to tell the python method opening your
> CSV file to use utf8 encoding, or use decode('utf-8') on the raw data.
>
> On Jun 30, 4:41 pm, prakhil samar <[email protected]> wrote:
>
>
>
> > Hi All
>
> > Please help me out with theUNICODEissue on Google App Engine
>
> > As GAE is using Python 2.5 which has default encoding system as
> > "ASCII" and python 3.0 has default encoding system as "UNICODE"
>
> > I have created one CSV file which contains someunicodecharacters
> > like  à á â these characters are not in ASCII range, so when i import
> > the CSV file i get following error:
>
> > " <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode
> > byte 0xe0 in position 0: ordinal not in range(128) "
>
> > I have set the default encoding as "UTF 8 " in the Lib folder of
> > Python 2.5 and it works all fine at my local server but when i deploy
> > the application on the Google App server then it gives me the above
> > error.
>
> > Is there any way to set the default encoding for my application on
> > Google App Engine platform ??
>
> > Is there any new version of Google Appengine supporting Python 3.0 ??
>
> > Anyone out there please help me out to resolve this issue
>
> > Thanks in Advance
> > Prakhil :)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to