Hello,
I would like to read and print files, of which the complete filepaths
are
mentioned in another textfile. In this textfile (list.txt) are for
example the following paths:
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_1LG_f01.TextGrid
/data/chorec/chorec-nieuw/s01/S01C001M1/
S01C001M1_1LGPseudo_f01.TextGrid
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_AVI1_f01.TextGrid
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
Antar2 5 1558
Le Wednesday 25 June 2008 20:59:38 antar2, vous avez écrit*:
Hello,
I would like to read and print files, of which the complete filepaths
are
mentioned in another textfile. In this textfile (list.txt) are for
example the following paths:
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_1LG_f01.TextGrid
/data/chorec/chorec-nieuw/s01/S01C001M1/
S01C001M1_1LGPseudo_f01.TextGrid
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_AVI1_f01.TextGrid
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
What's the problem exactly ? If you already know how to read a file you have
all what you need:
f_list = open('list.txt')
for filename in f_list :
f = open(filename)
print f.read()
f.close()
f_list.close()
If you get an error, please post the full error message with the backtrace.
--
Cédric Lucantis
On 25 juin, 20:59, antar2 <desoth...@yahoo.comwrote:
Hello,
(snip repost of the very same question)
I already got one answer for this question, but it did not work
For which definition of "did not work" ? How is your code ? What did
you expect, and what did you get ? Sorry to ask these questions, but
my crystal ball is currently down for maintainance...
On Jun 26, 1:59*am, antar2 <desoth...@yahoo.comwrote:
Hello,
I would like to *read and print files, of which the complete filepaths
are
*mentioned in another textfile. In this textfile (list.txt) *are for
*example the following paths:
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_1LG_f01.TextGrid
*/data/chorec/chorec-nieuw/s01/S01C001M1/
*S01C001M1_1LGPseudo_f01.TextGrid
*/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_AVI1_f01.TextGrid
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...
Is this Window's path or Unix-like's path. In Windows, path is
generally like this:
"folder\\data.txt" OR r"folder\data.txt"
because Windows use backslash as its path separator
In Unix-like OS (Unix, Linux, OSX), they use forward slash.
In general, Windows (Explorer) doesn't care whether you used backslash
or forward slash, but I'm not sure if we can use forwardslash in
Python.
I already got one answer for this question, but it did not work
It didn't work... how? Any error message? or what's the content of the
name that should be file object.
>
Thanks a lot
Antar2
antar2 wrote:
Hello,
I would like to read and print files, of which the complete filepaths
are
mentioned in another textfile. In this textfile (list.txt) are for
example the following paths:
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_1LG_f01.TextGrid
/data/chorec/chorec-nieuw/s01/S01C001M1/
S01C001M1_1LGPseudo_f01.TextGrid
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_AVI1_f01.TextGrid
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
Antar2
-- http://mail.python.org/mailman/listinfo/python-list
---------------------------------
I think what you want is more like:
contents of a file named printthem.py
......
import os
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 f.read()
f.close()
print '\n\t\t\t\tEND OF FILE\x0C'
p.close()
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
norseman
On Jun 25, 10:00*pm, norseman <norse...@hughes.netwrote:
antar2 wrote:
Hello,
I would like to *read and print files, of which the complete filepaths
are
*mentioned in another textfile. In this textfile (list.txt) *are for
*example the following paths:
/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_1LG_f01.TextGrid
*/data/chorec/chorec-nieuw/s01/S01C001M1/
*S01C001M1_1LGPseudo_f01.TextGrid
*/data/chorec/chorec-nieuw/s01/S01C001M1/S01C001M1_AVI1_f01.TextGrid
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
Antar2
-- http://mail.python.org/mailman/listinfo/python-list
---------------------------------
I think what you want is more like:
contents of a file named printthem.py
.....
import os
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 f.read()
* * *f.close()
* * *print '\n\t\t\t\tEND OF FILE\x0C'
p.close()
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
norseman
FYI, Python also understands '\f' ('\x0c').
Interestingly, print repr('\a\b\f\n\r\t\v') gives '\x07\x08\x0c\n\r\t
\x0b'. Is that because '\n', '\r' and '\t' occur so often that it was
decided that they should be treated specially? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jnc |
last post by:
Hi,
I was wondering if anybody had any pointers on the following:
I need to write some code which takes a list of file paths and
transforms them into a treeview which shows the directory...
|
by: James Kunicki |
last post by:
Hello,
I would like to know if anyone as found a way to
list a image next to a list box to indicate what type of
drive (local or network) and a folder
I would like to present in a user...
|
by: Stu |
last post by:
Hi,
I am writing a windows forms app that needs to list all the virtual servers
and their respective log file paths. The IIS6 metabse is nice and easy as it
is XML.
Is there any way to...
|
by: tigrrgrr42 |
last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am
currently bringing them from a byte array into a temp file to pop into word
and make word do its thing as a com object. ...
|
by: Vesa Leppanen |
last post by:
Hi,
I am new in python-list and quite new in Python programming as well. I
am working mainly with GIS and using Esri's geoprocessing tools.
I want to use .ini file to set the parameters,...
|
by: dave6502 |
last post by:
Struggling newbe here, some of my #includes work, some dont. Is it
possible to list the include path ? (in BASH),
I have looked at the environmental variables (loads of them) but
cannot find a...
|
by: antar2 |
last post by:
Hello,
Suppose this is a stupid question, but as a python beginner I
encounter a lot of obstacles... so I would be very grateful with some
help for following question:
I would like to read...
|
by: Justin |
last post by:
Here's my XML:
<?xml version="1.0" ?>
<AppMode Type="Network">
<CurrentFolder Path="c:\tabs">
<Tabs>
<FilePath>tabs\Justin.tab</FilePath>
<FilePath>tabs\Julie.tab</FilePath>
*****There could...
|
by: drewgy |
last post by:
Can anyone tell me how to get a list of full UNC paths for all printers on a network?
I have tried using WMI but the following code only gives me a list of local printers, and doesn't give me the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |