[Tutor] Read a file text and write on another one !

Khalid MOULFI kmoulfi@emirates.net.ae
Thu, 18 May 2000 14:30:18 +0400


Hi python world, every body,

first thanks to all who help me to install pyhon 1.5.2 on AIX 3.2.5.
Really, thank you !

Second, I have a request as I'm new and try to program with python.

I would like to read a text file formated as follow :

7043         710980033          05/09/2000 10:00:36
2044         710930005          05/09/2000 10:02:17
7043         710950008          05/09/2000 10:02:23
2044         710900001          05/09/2000 10:03:33
2044         710900004          05/09/2000 10:04:55
2044         710900003          05/09/2000 10:05:25
7043         710900019          05/09/2000 10:06:19

and try to read lines 49,66,72,89,95,112,...
to put these lines in another text file, sorted by the first column.

Some questions :

Is there any command to read the number of lines of the input file text ?
Like this, I will try to use the while command.

Is there anyway after sorting the output file to have the number of lines
per user
which is the first column ?

Another request :

I tried in a test file to launch the command :

----
import os

file = open('t1.txt','r')
os.system('ls -al ' + file)

I had when I launched it the following outputs :

<closed file '/test/koko.startup', mode 'w' at 20095078>
Traceback (innermost last):
  File "ex3.py", line 25, in ?
  	cmd = 'ls -al ' + file
TypeError: illegal argument type for built-in operation
----

Thanks to anybody who can help me!

khalid