<div>Hello members:</div>
<div> </div>
<div>I'm starting an script for geospatial information using python and gdal binaries, but I have problems saving the data I get into an excel shee. At the beginning I thought it was because the characters the files have for some records, but I run the code in a way it saves the path for each file I'm looking for. The script throws th error:</div>
<div>Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on<br>win32<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> import imagen<br>
Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br> File "imagen.py", line 20, in <module><br> wrkbk.save('imagen.xls')<br> File "C:\Python26\lib\site-packages\xlwt\Workbook.py", line 634, in save<br>
doc.save(filename, self.get_biff_data())<br> File "C:\Python26\lib\site-packages\xlwt\Workbook.py", line 609, in get_biff_d<br>ata<br> shared_str_table = self.__sst_rec()<br> File "C:\Python26\lib\site-packages\xlwt\Workbook.py", line 571, in __sst_rec<br>
return self.__sst.get_biff_record()<br> File "C:\Python26\lib\site-packages\xlwt\BIFFRecords.py", line 53, in get_biff<br>_record<br> self._add_to_sst(s)<br> File "C:\Python26\lib\site-packages\xlwt\BIFFRecords.py", line 66, in _add_to_<br>
sst<br> u_str = upack2(s, self.encoding)<br> File "C:\Python26\lib\site-packages\xlwt\UnicodeUtils.py", line 50, in upack2<br> us = unicode(s, encoding)<br>UnicodeDecodeError: 'ascii' codec can't decode byte 0xf3 in position 49: ordinal<br>
not in range(128)<br>>>></div>
<div>My code is:</div>
<div>import os, time, socket<br>from xlwt import Workbook<br>from osgeo import gdal<br>from osgeo.gdalconst import *<br>from PIL import Image</div>
<div><br>gdal.AllRegister()<br>file_list = []<br>folders = None<br> # look in this (root) folder for files with specified extension<br>for root, folders, files in os.walk( "C:\\" ):<br> file_list.extend(os.path.join(root,fi) for fi in files if fi.endswith(".tif") or fi.endswith(".tiff") or fi.endswith(".gtif") or fi.endswith(".ecw") or fi.endswith(".bil") or fi.endswith(".til") or fi.endswith(".jpeg"))<br>
wrkbk = Workbook()<br>wksht = wrkbk.add_sheet('rasters') <br>wksht.row(0).write(0,'ruta')<br>for row, filepath in enumerate(file_list, start=1): <br> #Llenar lista de archivos y ruta<br> wksht.row(row).write(0, filepath)<br>
wrkbk.save('imagen.xls')</div>
<div> </div>
<div>Is there a way I can manage this error?</div>