[Tutor] Counting lines per 1st column from an text file ?
Emile van Sebille
emile@fenx.com
Thu, 25 May 2000 05:04:35 -0700
To get you started, look at using readlines() to get
the file, string.split to break it into columns,
dictionaries to store the results, and slices to
pick off the first character.
HTH,
Emile van Sebille
emile@fenx.com
-------------------
----- Original Message -----
From: Khalid MOULFI <kmoulfi@emirates.net.ae>
To: <tutor@python.org>
Sent: Thursday, May 25, 2000 2:07 AM
Subject: [Tutor] Counting lines per 1st column from an text file ?
> Hello everybody,
>
> thanks to guys who answered me last time, you really helped me.
>
> I have another request, I have a text file with following lines :
>
> 1000 12345678 10/01/00 12:09:14 8
> 1005 12345678 10/01/00 12:09:14 8
> 1000 12345678 10/01/00 12:09:14 8
> 1006 12345678 10/01/00 12:09:14 8
> 1006 12345678 10/01/00 12:09:14 8
> 1005 12345678 10/01/00 12:09:14 8
> 1000 12345678 10/01/00 12:09:14 8
> 2004 12345678 10/01/00 12:09:14 8
> 2004 12345678 10/01/00 12:09:14 8
>
> I would like to know if it's possible to have the following outputs:
>
> 1/
> 1st column Nbr of lines
> 1000 3
> 1005 2
> 1006 2
> 2004 2
>
> 2/
> if fist character from the the first column is:
>
> 1 so I'l have total of lines 7
> 2 so I'l have total of lines 2
> 3..
> 4...
> and the print out could be :
> 1 -- 7
> 2 -- 2
>
> Thanks to anybody who ould help me
>
> Khalid
>
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>