I have a ascii data file with 1 line of header and 1 line of trailer - the 1st line and the LAST line in the data file. These 2 lines do not have any specific value to distinguish from them.
The lines in between are the data rows, with fixed-length columns.
Thus, I cannot use segmented-line method to parse this file. But I cannot find a way to include a trailer, and to handle fixed-length columns.
Can anyone help to provide a solution? Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The big question is: how do you know that you have reached the trailer? Do you simply count the paragraphs and when they reach some defined number, then the next paragraph, line is the trailer?
Answer this and we can look into solutions.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-09-09
How do I know I have reached the trailer?
The LAST line is the trailer. There is NO specific pattern in the trailer line that tell us it is the trailer. But the LAST line in the data file is the trailer.
Let's see the sample data file:
###20040901020142XXXXXX
Record 1This is the 1st record
Record 2This is the 2nd record
.............(repeat)..................
Record N This is the Nth record
###00000N
You can see that the 1st line is the header line with a timestamp field and other info as well.
The LAST line is the trailer with a total number of record field, for verification.
Since both the header and trailer has the same pattern (###), and NO pattern for data lines, we cannot use the segmented-line method.
Any idea?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A modified question.
I have a ascii data file with 1 line of header and 1 line of trailer - the 1st line and the LAST line in the data file. These 2 lines do not have any specific value to distinguish from them.
The lines in between are the data rows, with fixed-length columns.
Thus, I cannot use segmented-line method to parse this file. But I cannot find a way to include a trailer, and to handle fixed-length columns.
Can anyone help to provide a solution? Thanks.
The big question is: how do you know that you have reached the trailer? Do you simply count the paragraphs and when they reach some defined number, then the next paragraph, line is the trailer?
Answer this and we can look into solutions.
How do I know I have reached the trailer?
The LAST line is the trailer. There is NO specific pattern in the trailer line that tell us it is the trailer. But the LAST line in the data file is the trailer.
Let's see the sample data file:
###20040901020142XXXXXX
Record 1This is the 1st record
Record 2This is the 2nd record
.............(repeat)..................
Record N This is the Nth record
###00000N
You can see that the 1st line is the header line with a timestamp field and other info as well.
The LAST line is the trailer with a total number of record field, for verification.
Since both the header and trailer has the same pattern (###), and NO pattern for data lines, we cannot use the segmented-line method.
Any idea?
Is N a fixed or known number?
Otherwise you can just do this by making a XSL that swallows the last line.
N is neither fixed or known.
So there is no direct support to handle this case. I will try to use XSL to solve this.
Thanks very much.