[Tutor] Attempt to overwrite excel cell Python
Susana Iraiis Delgado Rodriguez
susana.delgado_s at utzmg.edu.mx
Thu Oct 14 15:13:43 CEST 2010
Hi Walter!
I already looked at the code you suggested me to accomplish my goal, I made
some changes on it to match mine, your code is very neat and nice. Here are
some lines I changed:
- First I did the file search
file_list = []
folders = None
for root, folders, files in os.walk( "C:\\" ):
file_list.extend(os.path.join(root,fi) for fi in files if
fi.endswith(".shp"))
- Then I create the excel, and asign the writing to the cells:
wksht = wrkbk.add_sheet('shp')
wksht.row(0).write(0,'archivo')
wksht.row(0).write(1,'x_min')
wksht.row(0).write(2,'y_min')
wksht.row(0).write(3,'x_max')
wksht.row(0).write(4,'y_max')
wksht.row(0).write(5,'geometria')
wksht.row(0).write(6,'num_elem')
wksht.row(0).write(7,'prj')
wksht.row(0).write(8,'estrutura bd')
wksht.row(0).write(9,'extent')
wksht.row(0).write(10,'fecha_modificacion')
wksht.row(0).write(11,'maquina_host')
for row, filepath in enumerate(file_list, start=1):
wksht.row(row).write(0, filepath)
wrkbk.save('shp.xls')
SEARCH_PATH = os.getcwd()
TARGET_FILE = os.path.realpath('shp.xls')
print "Searching in", SEARCH_PATH, "and writing to", TARGET_FILE
print "Finding files..."
print "Writing Excel file..."
print "Done."
2010/10/13 Susana Iraiis Delgado Rodriguez <susana.delgado_s at utzmg.edu.mx>
> Hi Walter!
>
> I already looked at the code you suggested me to accomplish my goal, I made
> some changes on it to match mine, your code is very neat and nice. Here are
> some lines I changed:
>
> - First I did the file search
>
> file_list = []
> folders = None
> for root, folders, files in os.walk( "C:\\" ):
> file_list.extend(os.path.join(root,fi) for fi in files if
> fi.endswith(".shp"))
>
> - Then I create the excel, and asign the writing to the cells:
>
> wksht = wrkbk.add_sheet('shp')
> wksht.row(0).write(0,'archivo')
> wksht.row(0).write(1,'x_min')
> wksht.row(0).write(2,'y_min')
> wksht.row(0).write(3,'x_max')
> wksht.row(0).write(4,'y_max')
> wksht.row(0).write(5,'geometria')
> wksht.row(0).write(6,'num_elem')
> wksht.row(0).write(7,'prj')
> wksht.row(0).write(8,'estrutura bd')
> wksht.row(0).write(9,'extent')
> wksht.row(0).write(10,'fecha_modificacion')
> wksht.row(0).write(11,'maquina_host')
>
>
> for row, filepath in enumerate(file_list, start=1):
> wksht.row(row).write(0, filepath)
> wrkbk.save('shp.xls')
>
>
> SEARCH_PATH = os.getcwd()
> TARGET_FILE = os.path.realpath('shp.xls')
> print "Searching in", SEARCH_PATH, "and writing to", TARGET_FILE
> print "Finding files..."
> print "Writing Excel file..."
> print "Done."
>
> 2010/10/12 Walter Prins <wprins at gmail.com>
>
> Hi just a quick note -- I included my own recursive call in the code I
>> posted last night which is obviously superflous as os.walk() already
>> recurses by itself. So if you looked at it already you may want to look at
>> it again.
>>
>> Walter
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101014/f88bafa0/attachment.html>
More information about the Tutor
mailing list