Hi,
I'm looking for a way to get to the end of a text file, so I can read the last line in to extract some pertinent information. Unfortunatly, I can't read the entire text file into an an array and perform the operations in memory, because the textfiles contain 5-6 million lines - typically.
Basically, the format of the file (awkwardly), is that there is pertinent information on the top line, and the last line, and then the millions of records populate the in-between:
CUST NAME: Joe Blogs, DATA: data, DATA: data (First Line)
001, 1234, 5678 (Records)
002, 1234, 5678
003, 1234, 5678
004, 1234, 5678
...--->to infinity & beyond!
CUST ACCNT: 99199299 CUST PREFIX: BSN211 (Last Line - Format varies)
I want to seek to the line prior to EOF being true, so I can pull out the value, reset the position in the file to the first line, and continue parsing. It would also be good if the current line I am processing could be checked against the files last line, e.g. CurrentLine = 10 LastLine = 151 so that I don't have to A) right a bunch of statements to test the contents of each line to determine if it's the last one and B) so I don't accidentally process the last line using the standard record processing (which would produce garbage).
In a nutshell, I know where the data is, I know what format it will typically arrive in, I just can't figure out how to reach it easily.
Thanks for any help.
Yum.
I'm looking for a way to get to the end of a text file, so I can read the last line in to extract some pertinent information. Unfortunatly, I can't read the entire text file into an an array and perform the operations in memory, because the textfiles contain 5-6 million lines - typically.
Basically, the format of the file (awkwardly), is that there is pertinent information on the top line, and the last line, and then the millions of records populate the in-between:
CUST NAME: Joe Blogs, DATA: data, DATA: data (First Line)
001, 1234, 5678 (Records)
002, 1234, 5678
003, 1234, 5678
004, 1234, 5678
...--->to infinity & beyond!
CUST ACCNT: 99199299 CUST PREFIX: BSN211 (Last Line - Format varies)
I want to seek to the line prior to EOF being true, so I can pull out the value, reset the position in the file to the first line, and continue parsing. It would also be good if the current line I am processing could be checked against the files last line, e.g. CurrentLine = 10 LastLine = 151 so that I don't have to A) right a bunch of statements to test the contents of each line to determine if it's the last one and B) so I don't accidentally process the last line using the standard record processing (which would produce garbage).
In a nutshell, I know where the data is, I know what format it will typically arrive in, I just can't figure out how to reach it easily.
Thanks for any help.
Yum.