ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Issue with line wrap in source txt file when importing- please help (https://www.excelbanter.com/excel-programming/325544-issue-line-wrap-source-txt-file-when-importing-please-help.html)

KR

Issue with line wrap in source txt file when importing- please help
 
I am getting a text file whose source I have no control over. In this text
file, when I use the import wizard in excel, I can parse each line in all
the right places, and pull my data into a worksheet.

However, when I use the commands to read a line at a time (I need the stuff
in an array, but don't need it actually imported into a worksheet) such as:

Open LongFN For Input As #1
Do While Not EOF(1)
Line Input #1, LineofText

the lines that are wrapped in the file end up coming in as /multiple/ lines
when I read the file a line at a time.

I have almost 30 discrete groups of data in some lines, so they wrap up to 3
or 4 lines. Trying to reconstruct the data from multiple lines (each data
group might have a different number of lines) would be a nightmare.

Is there a setting or a way to read a line all the way to the next "line
break" as seen by the import wizard, rather than truncating each line at
whatever the current setting is (probably 80 chars)? In the import wizard it
looks like the maximum is just over 700 characters. I suspect the issue is
that Line Input looks at either Chr(13) or (Chr(10)&Chr(13)), but I want it
to skip any Chr(13) and keep reading automatically until it hits a
(Chr(10)&Chr(13))

Please, please help.
Thank you,
Keith

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.



KR

Issue with line wrap in source txt file when importing- please help
 
Nevermind- I have no idea why, but now it is working as expected. I wish I
knew why so I could prevent myself from changing back whatever it was that
fixed it, but at least for now it is working. Yea!
Thanks,
Keith

"KR" wrote in message
...
I am getting a text file whose source I have no control over. In this text
file, when I use the import wizard in excel, I can parse each line in all
the right places, and pull my data into a worksheet.

However, when I use the commands to read a line at a time (I need the

stuff
in an array, but don't need it actually imported into a worksheet) such

as:

Open LongFN For Input As #1
Do While Not EOF(1)
Line Input #1, LineofText

the lines that are wrapped in the file end up coming in as /multiple/

lines
when I read the file a line at a time.

I have almost 30 discrete groups of data in some lines, so they wrap up to

3
or 4 lines. Trying to reconstruct the data from multiple lines (each data
group might have a different number of lines) would be a nightmare.

Is there a setting or a way to read a line all the way to the next "line
break" as seen by the import wizard, rather than truncating each line at
whatever the current setting is (probably 80 chars)? In the import wizard

it
looks like the maximum is just over 700 characters. I suspect the issue is
that Line Input looks at either Chr(13) or (Chr(10)&Chr(13)), but I want

it
to skip any Chr(13) and keep reading automatically until it hits a
(Chr(10)&Chr(13))

Please, please help.
Thank you,
Keith

--
The enclosed questions or comments are entirely mine and don't represent

the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.






All times are GMT +1. The time now is 08:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com