import only the first part of a text file

  • Thread starter Thread starter L Mehl
  • Start date Start date
L

L Mehl

Hello --

An external application generates a text file which looks like the text
between the lines:
-----------------------------
ARRAY 1 6
#X-values
30.201515
30.260118
30.330780
33.360526
33.430092
34.737403
< --- blank
line
#Y-values
1.860447
0.058603
0.070662
3.029746
0.069566
0.870192
-----------------------------
Our charting process imports the text file, but needs only the data above
the blank line.

It is possible that the top part of the data could contain as many as
65,500, so I can't simply import the whole file into a worksheet and use the
top part for data.

It looks like I will have to read the text file line-by-line until I reach
the blank line.

Can anyone suggest examples of processing text files, or give me some
pointers on how to do it?

Thanks for any help.

Larry Mehl
 
Larry -

You can use VBA's file IO to read this. Open the file in VBA, read line
by line into a VBA array, stop when you get to the blank line, then dump
the array into the worksheet. It goes faster than "line-by-line" implies.

- Jon
 
Jon --

Thank you. I am learning a lot by pursuing your responses to my requests
for help.

Larry
 
Back
Top