Re: Linefeed to CrLf



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

Sub test()
Debug.Print Replace(ReadAll("c:\bigFile.txt"), vbLf,
vbCrLf)
End Sub
Would be faster to write back to disk and do a file import,
or just use mid() to split the string and stuff it into the
table
I can't answer that because I do not know what you have to do
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.


.



Relevant Pages

  • Re: Code to check if a valid e-mail address was entered
    ... Function Valid_Email(E_Address As String) As Boolean ... ' Note that the part after the @ sign must contain at least one dot, ... ' at least one other character following it, ... Dim TString As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Document Property to display more than 1 line
    ... then use the following macro to identify the character ... Dim strNums As String ...
    (microsoft.public.word.newusers)
  • Code problem Help!
    ... Dim strCompname As String ... Dim strFirstname As String ... strFirstname & vbCrLf & _ ...
    (microsoft.public.access.formscoding)
  • Re: Eval code and AppDomains
    ... Crossing app domains and generating these assemblies ... > I needed a way to Eval this string and return a Boolean result. ... > Dim objEval As New EvalProvider ... > sb.Append("Imports System.Data" & vbCrLf) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Copying files from the CD using SHFileOperation API
    ... > pFrom As String ... > Dim sOrigin As String ... > Dim SHFileOp As SHFILEOPSTRUCT ... VB terminates with a null character automatically. ...
    (microsoft.public.vb.winapi)