473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Linefeed to CrLf

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?

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 9 '07 #1
10 6462
On 09 Mar 2007 21:26:51 GMT, Bob Quintal <rq******@sPAmpatico.ca>
wrote:

So you write some code to pre-process the file before importing it,
replacing CR with CRLF.
-Tom.

>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?

--
Bob Quintal

PA is y I've altered my email address.
Mar 10 '07 #2
rkc
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
Mar 10 '07 #3
On Fri, 09 Mar 2007 23:14:07 -0500, rkc <rk*@rkcny.yabba.dabba.do.com>
wrote:

Sweet. Unless the file was more than 2GB.
Nah, no Unix system that bad !

-Tom.

>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
Mar 10 '07 #4

Found some alternatives here, but I haven't tried them...

http://groups.google.ca/group/comp.d...5f1f81bb18cff2

Mar 10 '07 #5
That is impressive! I'll test it out on monday.

I should be much faster than the Do while LOC < LOP() loop I was
using.

Thanks for the time.

rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45***********************@roadrunner.com:
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


--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 10 '07 #6
rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45***********************@roadrunner.com:
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

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 10 '07 #7
rkc
Bob Quintal wrote:
rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45***********************@roadrunner.com:
>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.


Mar 10 '07 #8
rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45**********************@roadrunner.com:
Bob Quintal wrote:
>rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45***********************@roadrunner.com:
>>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.

I'll report back.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 10 '07 #9
rkc
Bob Quintal wrote:
rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45**********************@roadrunner.com:
>Bob Quintal wrote:
>>rkc <rk*@rkcny.yabba.dabba.do.comwrote in
news:45***********************@roadrunner.com:

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

Mar 10 '07 #10
On Mar 10, 1:04 pm, rkc <r...@rkcny.yabba.dabba.do.comwrote:
Bob Quintal wrote:
rkc <r...@rkcny.yabba.dabba.do.comwrote in
news:45**********************@roadrunner.com:
Bob Quintal wrote:
rkc <r...@rkcny.yabba.dabba.do.comwrote in
news:45***********************@roadrunner.com:
>>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.
Mar 12 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: eddie wang | last post by:
What is CRLF? Thanks. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
by: Johannes Busse | last post by:
Hello, I use saxon 6.5.3. under SuSE 9.1. In my stylesheet I give out messages like <xsl:message> <xsl:value-of select="$myId" /> <xsl:text> | </xsl:text> </xsl:message>
4
by: McKirahan | last post by:
How would I use a regular expression to remove all trailing Carriage Returns and Line Feeds (%0D%0A) from a textarea's value? Thanks in advance. Also, are they any great references for learning...
2
by: Jürgen Heyn | last post by:
Good afternoon, in a form a multiline textbox is defined: <textarea name="text" cols="25" rows="3">This is the text. this should be line 2</textarea> In the textbox the linefeed is displayed...
5
by: McKirahan | last post by:
I'd like to use regular expressions to remove extraneous Carriage Return Line Feeds (CrLf) from a textarea before the form is submitted. I'd like to remove all trailing CrLf's and convert all...
3
by: Wade G. Pemberton | last post by:
Help!: I use javascript to format repetitive data from a web page input FORM into a long string , and save it as lines of comma delimited data in a text file on a Unix server. The text...
1
by: Jack Wright | last post by:
Dear All, In a multiline field if I enter the following way: Mangesh Anant Kodilkar There is a carriage return after each word. Now when I press save,it loses the CRLF characters. This is not...
2
by: Michael Persaud | last post by:
Hi All, Im trying to have a few strings presented in a LABEL. However the CRLF is not working. eg str = str1 + crlf + str2 + crlf + str3 label.text= str Do i need to declare the crlf as a...
2
by: Andrew | last post by:
Hello. I am working with very large files in my .NET project (1 million plus records). Some of these files do not have crlf's, which makes it very hard to read the file without a layout or record...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.