Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change the line delimiter for input files

Status
Not open for further replies.

Sean7174

Programmer
Jul 17, 2003
13
US
How can you change the line delimiter that vba uses for the “read line” command? I am trying to read data files generated in a Unix environment, which only uses LF, not the CRLF that VBA is looking for.
 
what command are you presently using to read the file?
 
Here is a summery of the code:

FPath="UnixDataFile"
Open FPath For Input As #1
Do While Not EOF(1)
Line Input #1, Single_Line
Loop
Close #1

Unix uses only a LF (Chr 10), which is not recognized by VBA as a line brake. When this code runs, it only takes 1 pass to read the entire file. The working solution I have now is to pass the line through a "Split" function (Too bad one does already not exist in Excel 97 VBA). Other solutions would be to pass the data files through a "Unix2Dos" command on the Unix boxes, but this is undesirable due to the large number of files I am working with. Plus, I would just like to know if it is possible to change the line delimiter. (Or maybe I got spoiled with AWK).
 
have you considered opening the file For Binary and reading it byte by byte?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top