I have txt and csv files to be read per line. A line ends with CR-LF
.
But in some files, there is CR
and no LF
; instead, next physical line starts with FF
. UFT 12 reads them together, as if it was one line.
I read files using fso:
Dim FileRead : Set FileRead = fso.OpenTextFile(file1)
Dim file2Read : Set file2Read = fso.OpenTextFile(file2)
FileStrR = FileRead.ReadLine
File2StrR = FileRead.ReadLine
I need to compare each line of these file with another text file:
if FileStrR = File2Str Then...
I tried to separate the FileStrR
as array:
FileStrA = REPLACE(FileStrR, ChrW(12),"**")
strarray = split(FileStrA,"**")
For h = 0 to UBound(strarray)
FileStr = strarray(h)
if FileStr = File2Str Then...
...
But here I stuck to read next line from the File2 to compare with whatever comes after FF
.
UPDATE Tried to SkipLine:
Do Until fileRead.AtEndOfStream
ln=ln+1
FileStrA = REPLACE(FileStrR, ChrW(12),"**")
strarray = split(FileStrA,"**")
For h = 0 to UBound(strarray)
FileStr = strarray(h)
For s=1 to (ln+h)-1
File2Read.SkipLine
Next
print ln&"-"&ln+h&"-"&h
File2Str = File2Read.ReadLine
if FileStr1 = File2Str Then...
print "F1: "&FileStr
print "F2: "&File2str
Next
Loop
In this peace of code, the line print ln&"-"&ln+h&"-"&h
prints correct numbers (ln should be the number of the line currently read). But the string print (print "F1: "&FileStr & VBNewLine & "F2: "&File2str
)gives the following:
F1: 2|8122|TX|...
F2: 4|8123|FG|...
It seems even if ln+h
is 'ln' while 'h' is 0, but the fso
skips one more line.