Home All Groups Group Topic Archive Search About

Reading text file with variable field widths

Author
8 Nov 2006 11:55 AM
Christie
I am using Visual Studio 2005 (VB.Net) to write my app.  At some point
the app. need to read a text file with data in columner format.  The
problem I have is that the columns are of variable width (not fixed).
Is there a way that I can use white space characters to distinguise
between different fields in a row?

The file is not comma or tab delimited, but it has spaces between
fields.  Spaces are present only between individual fields, never in
the fields themselves.

Below is a couple of lines from the file.

1  PH5      902.0 MG            2 T1ORE    1 ORE1      2000       ALL
       0.300

1  PH5      902.0 HB%           7 WS101  101 WST1      2000       ALL
       0.600

1  PH9     1172.0 FD%           4 WS101  101 WST1      2000       ALL
       0.500



Thanks

Author
8 Nov 2006 2:05 PM
C-Services Holland b.v.
Christie wrote:

Show quoteHide quote
> I am using Visual Studio 2005 (VB.Net) to write my app.  At some point
> the app. need to read a text file with data in columner format.  The
> problem I have is that the columns are of variable width (not fixed).
> Is there a way that I can use white space characters to distinguise
> between different fields in a row?
>
> The file is not comma or tab delimited, but it has spaces between
> fields.  Spaces are present only between individual fields, never in
> the fields themselves.
>
> Below is a couple of lines from the file.
>
> 1  PH5      902.0 MG            2 T1ORE    1 ORE1      2000       ALL
>        0.300
>
> 1  PH5      902.0 HB%           7 WS101  101 WST1      2000       ALL
>        0.600
>
> 1  PH9     1172.0 FD%           4 WS101  101 WST1      2000       ALL
>        0.500
>

>
> Thanks
>

They seem fixed width to me. You just have to decide where the borders
of the fields are.


--
Rinze van Huizen
C-Services Holland b.v