Re: Linefeed to CrLf
- From: "rquintal@xxxxxxxxxxxx" <bob.quintal@xxxxxxxxx>
- Date: 12 Mar 2007 11:52:44 -0700
On Mar 10, 1:04 pm, rkc <r...@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Bob Quintal wrote:
rkc <r...@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:45f2a168$0$8956$4c368faf@xxxxxxxxxxxxxx:
Bob Quintal wrote:
rkc <r...@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:45f2308f$0$24723$4c368faf@xxxxxxxxxxxxxx:
Bob Quintal wrote:
I'm receiving data in text files from a unix sustem that
onlu puts a Lf character at the end of each row. Access
insists on Cr or CrLf or it sees the file as 1 row 700Kb
wide and chokes.
Is there a better way of importing this file than using the
open #1 command and building strings in a do loop one
character at a time?
Function ReadAll(path As String) As String
Dim fh As Long
fh = FreeFile
Dim s As String
'add error handling
Open path For Binary As #fh
s = String$(LOF(fh), vbNullChar)
Get #fh, , s
Close fh
ReadAll = s
End Function
I can't answer that because I do not know what you have to doSub test()Would be faster to write back to disk and do a file import,
Debug.Print Replace(ReadAll("c:\bigFile.txt"), vbLf,
vbCrLf)
End Sub
or just use mid() to split the string and stuff it into the
table
with the file. I posted assuming you would just write it back
to a file and go from there.
I'll know monday. Currently I'm reading the fileup to a line
feed, and parsing that into the destination table. It should not
take long to code both ways and test which is faster.
If that's the case I might just try leaving it in memory after the
vbcrlf replace and doing something like:
dim lines as variant
dim count as long
lines = Split(WholeThing, vbcrlf)
for count = 0 to ubound(lines)
call Parse(lines(count))
next- Hide quoted text -
- Show quoted text -
Reading the whole file into a variable and parsing it down to lines
with mid() is 150 times faster than reading the file one byte at a
time and concatenating the bytes into the string
I don't know where I got the impression a variable was limited to 64Kb
but I'm sure glad you pointed out that it isn't.
Thanks again.
.
- References:
- Linefeed to CrLf
- From: Bob Quintal
- Re: Linefeed to CrLf
- From: rkc
- Re: Linefeed to CrLf
- From: Bob Quintal
- Re: Linefeed to CrLf
- From: rkc
- Re: Linefeed to CrLf
- From: Bob Quintal
- Re: Linefeed to CrLf
- From: rkc
- Linefeed to CrLf
- Prev by Date: Re: Comepare todays date with date + 60 days
- Next by Date: File > Open works, double-click doesn't work?
- Previous by thread: Re: Linefeed to CrLf
- Next by thread: Re: Linefeed to CrLf
- Index(es):
Relevant Pages
|