Prakhil,
Did you resolve this ?
You need to do the convertion to unicode before any split or strip,
try
csv_file = self.request.get('file1').decode('utf-8') on your first
line or if it is urlencoded:
csv_file = urllib.unquote( self.request.get('file1') ).decode('utf-8')On Jul 1, 3:45 pm, prakhil samar <[email protected]> wrote: > 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 > > -- 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.
