csv query

purplegerbil
11-30-2004, 08:54 AM
Hi,
I have a comma delimited file with a line feed after every 10th field.
I am trying to read read all 10 fields together to check for a certain word. usually a csv file has crlf on the end and this wouldnt be a problem by using Line Input.... I have tried to input the fields separately but the lf causes a problem.

Is there a way of being able to read in the data and ignore the line feed.

Any help would be great.

Thanks
PG

webbone
11-30-2004, 10:07 AM
You could read the entire file into a string and then use Split() with vbLf as the delimiter to create a string array that is all the lines in your file.


Option Explicit

Dim ff As Integer
Dim sWholeFile As String
Dim sFileLines() As String

ff = FreeFile
Open "myfile.ext" For Binary As ff

sWholeFile = Space(LOF(ff)) 'set your string size to the length of the file
Get #1, , sWholeFile 'read the entire file into the string

Close 1

sFileLines = Split(sWholeFile, vbLf) 'create an array of the lines in your file

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum