hi all...
ok so i have a file and what i wish to do is read all the lines usilng readline()

then for everyline i need to read and match lines and form groups.
how i need to do this is that say for example... line[0] match move to line[3] and while i have a match here. stop, count and form a group.
so say for example:

1 32 23 26............
1 1 65 26............ so while all list[0] values are same
1 22 55 26............ and all list[3]are same count
2 1 19 1.......
2 2 19 1.......
2 1 30 1.......

i have been reading the regular exp stuff, however i DO NOT KNOW what numbers will be i need to match i suppose... anything i can read? any websites etc that anyone can suggest... would be great

I am sorry, can you make your question more clear?

I would suggest you use 'readlines()' to convert the whole file to a list. Basically, I take it that you want to compare lines, is that it?

This is pretty straight forward and done quite often. It assumes, of course, that the file is already in a sorted order. First, declare an empty list to store the records in. Read the file one record at a time and extract the two fields you want to compare. If the two fields that you want to test are not equal to the previous record's, then send the list to a function which can do whatever you want to process the previous group of records in the list. Now declare the list as empty, once again, and append records until you hit the next break. Note that you will have to send the final list to the processing function after the read loop, as the final group of records have not been processed.

hi all...
ok so i have a file and what i wish to do is read all the lines usilng readline()

then for everyline i need to read and match lines and form groups.
how i need to do this is that say for example... line[0] match move to line[3] and while i have a match here. stop, count and form a group.
so say for example:

1 32 23 26............
1 1 65 26............ so while all list[0] values are same
1 22 55 26............ and all list[3]are same count
2 1 19 1.......
2 2 19 1.......
2 1 30 1.......

i have been reading the regular exp stuff, however i DO NOT KNOW what numbers will be i need to match i suppose... anything i can read? any websites etc that anyone can suggest... would be great

re sab786: you need to be clearer. Don't tell us what you've read, or what you don't know. We see a text file with lines. Each line has numbers in a list. The zeroth line starts with one, and so does the second line. Is that important to your method/function? Go easy on the big words. What the devil do you want?

This article has been dead for over six months. Start a new discussion instead.