reading from list with paths
norseman at hughes.net
Wed Jun 25 23:00:41 CEST 2008
> I would like to read and print files, of which the complete filepaths
> mentioned in another textfile. In this textfile (list.txt) are for
> example the following paths:
> I know how to open and read one file in my current directory,
> but after trying to find this out my self, I give up...
> I already got one answer for this question, but it did not work
> Thanks a lot
I think what you want is more like:
contents of a file named printthem.py
p = open('list.txt')
for vpath in p:
for f in os.listdir(vpath):
print '\n\tContents of:',vpath+'/'+f
f = open(vpath+'/'+f)
print '\n\t\t\t\tEND OF FILE\x0C'
print "All Done. Is there any paper left?"
usage: python printthem.py >/dev/lp0 Unix
python printthem.py > prn: Microsoft
On Microsoft use '\\' in place of '/' following each vpath above
The \x0C is Ctrl-L aka: ff or FormFeed
More information about the Python-list