[Tutor] How can I make a python script go directory by directory and excecute on files of choice
Liam Clarke
ml.cyresse at gmail.com
Wed Jan 11 04:58:56 CET 2006
Hi Srinivas -
For walking a directory, you can use os.walk() or os.path.walk(), but
I prefer the path module here -
http://www.jorendorff.com/articles/python/path/.
As for determining if a file is really an .XLS format file or a tab
delimited file with .xls on the end, go to www.wotsit.org, have a look
at the .XLS specifications; there'll probably be a sequence of
identifying bytes you can read to confirm that it's an XLS.
Regards,
Liam Clarke
On 1/11/06, Srinivas Iyyer <srini_iyyer_bio at yahoo.com> wrote:
> Dear group,
> I have Excel files that are arranged according to
> transctions under various name/directories.
>
> I found out that all these Excel files are not real
> OLE based files and some of them are really tab delim
> files with .XLS appended to the end of file name. I
> got fooled and started using pyExcelator module.
>
> Now I want to write a script that can go to each
> directory from base directory.
>
> Say: my dir path is like this:
>
> /home/srini/data/sales
> - jan05/(1-31).xls
> - feb05/(1-27).xls
> - mar05/(1-31).xls
>
> How can I ask my script residing in data directory to
> go to sales and scan all directories and report if
> .xls files are really Excel files or text files with
> .xls extension.
>
> could any one please help me here.
>
> thank you.
>
>
>
>
> __________________________________________
> Yahoo! DSL – Something to write home about.
> Just $16.99/mo. or less.
> dsl.yahoo.com
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list