Hello all,
What I'm dealing with...
I have a text file that is delimited by tabs (\t characters). The file could be viewed as having rows and columns. The rows are delimited by carriage returns/line feeds (\r\n characters), while the columns are delimited by one or more tabs (\t characters). The very first row makes up the heading of the file.
What I need to do...
I need to parse the file and extract the information it contains. For each row, I need to be able to identify each column because each column has a special meaning. Duh!
The problem I'm having...
The number of tabs (\t characters) that appear between each column varies from row to row. It appears that the file was created so that the columns line up visually and thus, the number of tabs between each column varies according to how long the text in each/column is. Certain columns may be blank, which causes the number of tabs to be more for the rows where such columns are blank. The text of in some columns varies from row to row, and when that's the case, the number of tabs between each column is, again, different.
For example, take a look at this:
Ok - the columns don't quite line up here and I guess that's because I have a different font. It's funny, though, that with the file I have, I could select any font, and the columns will still line up. In any case, the point is this: The number of \t characters is different between columns from row to row. In fact, in my example above, there are 4 \r characters between the data at the third column and the data at the 4th column in the second row - that is the first non-heading row). There's only 1 \r character, however, between the same columns on the third (and last) row. This little detail, combined with the fact that the number of characters of the data in each column differs for every row, makes identifying the columns a difficult task (at least for me).
The question...
Thus, the question is... How can I identify each column in each row, given the fact that the number of tabs between columns varies for each row?
Thanks!
JC
_________________________________________________
To get the best response to a question, read faq222-2244.
What I'm dealing with...
I have a text file that is delimited by tabs (\t characters). The file could be viewed as having rows and columns. The rows are delimited by carriage returns/line feeds (\r\n characters), while the columns are delimited by one or more tabs (\t characters). The very first row makes up the heading of the file.
What I need to do...
I need to parse the file and extract the information it contains. For each row, I need to be able to identify each column because each column has a special meaning. Duh!
The problem I'm having...
The number of tabs (\t characters) that appear between each column varies from row to row. It appears that the file was created so that the columns line up visually and thus, the number of tabs between each column varies according to how long the text in each/column is. Certain columns may be blank, which causes the number of tabs to be more for the rows where such columns are blank. The text of in some columns varies from row to row, and when that's the case, the number of tabs between each column is, again, different.
For example, take a look at this:
Code:
[b]Column1[/b] [b]Col2[/b] [b]ThisIsTheThirdAndLargestColumn3[/b] [b]Column4[/b]
Row1Col1 r1c2 row1col3 r1c4
r2c1 AsYouMayKnowThisIsTheSecondRowCol3
The question...
Thus, the question is... How can I identify each column in each row, given the fact that the number of tabs between columns varies for each row?
Thanks!
JC
_________________________________________________
To get the best response to a question, read faq222-2244.