Hello members: I'm using xlwt from python to work with excel, I'm developing some sort of system crawler to look for all the files ending with .shp, I took a look to csv, but I didn't understand it. Now, I have to create a .xls where people can save information from shp files, but first I have to create the excel and add a row for column names:
import os from xlwt import Workbook wb = Workbook() ws = wb.add_sheet('shp') ws.row(0).write(0,'archivo') ws.row(0).write(1,'x_min') ws.row(0).write(2,'y_min') ws.row(0).write(3,'x_max') ws.row(0).write(4,'y_max') ws.row(0).write(5,'geometria') ws.row(0).write(6,'num_elem') ws.row(0).write(7,'prj') ws.row(0).write(8,'estrutura bd') ws.row(0).write(9,'extent') ws.row(0).write(10,'fecha_modificacion') ws.row(0).write(11,'maquina_host') Then I have to do the crawler part to have the directory I want: allfiles = [] #store all files found for root,dir,files in os.walk("C:\\"): filelist = [ os.path.join(root,fi) for fi in files if fi.endswith(".shp") ] for f in filelist: allfiles.append(f) Now I want to get the name of the file and write it uder the column "Archivo", the variable i has the name of each file: for i in allfiles: print i ws.row(1).write(0,i) wb.save('shp.xls') But when I run it, it throws me the error: *Exception*: *Attempt to overwrite cell*: sheetname='shp' rowx=1 colx=0, don't know what is wrong
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor