473,320 Members | 1,883 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,320 software developers and data experts.

ASCII file without crlf's

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 length.
In my application, I would like to open one of these text files and
check to see if it contains crlf's before proceeding in my code. I
tried using the streamreader, but readline() cancels out with a memory
error because it thinks the ENTIRE file is first record since there
are no crlf's. I have also tried FSO, but I get a server timeout.

Is there any easy way to check for crlf's with files like this?

Thanks!
Nov 20 '05 #1
3 2198
Open the file and instead of using readline, just use read passing 1 as length.
Compare that single character as a vbCr or vbLf. If you *must* check for vbCrLf,
you should watch out because sometimes they are backwards, vbLf & vbCr.

Hope this helps,
Mythran

"Andrew" <ne*************@yahoo.com> wrote in message
news:7d**************************@posting.google.c om...
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 length.
In my application, I would like to open one of these text files and
check to see if it contains crlf's before proceeding in my code. I
tried using the streamreader, but readline() cancels out with a memory
error because it thinks the ENTIRE file is first record since there
are no crlf's. I have also tried FSO, but I get a server timeout.

Is there any easy way to check for crlf's with files like this?

Thanks!

Nov 20 '05 #2
Use a BinaryReader, and read in say 128 bytes at a time - vByteArray =
vBinReader.ReadBytes(128)
Then check the array for bytes of value 10 or 13 - or as Mythran says,
combinations of 10, 13, 10 & 13 or 13 & 10.
_____________________________
The Grim Reaper

"Mythran" <ki********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP11.phx.gbl...
Open the file and instead of using readline, just use read passing 1 as length. Compare that single character as a vbCr or vbLf. If you *must* check for vbCrLf, you should watch out because sometimes they are backwards, vbLf & vbCr.

Hope this helps,
Mythran

"Andrew" <ne*************@yahoo.com> wrote in message
news:7d**************************@posting.google.c om...
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 length.
In my application, I would like to open one of these text files and
check to see if it contains crlf's before proceeding in my code. I
tried using the streamreader, but readline() cancels out with a memory
error because it thinks the ENTIRE file is first record since there
are no crlf's. I have also tried FSO, but I get a server timeout.

Is there any easy way to check for crlf's with files like this?

Thanks!


Nov 20 '05 #3
thanks guys for you help. works great now.

Dim fs As System.IO.FileStream = New
System.IO.FileStream("C:\upload\cas001-987607\input.txt",
IO.FileMode.Open)

Dim vByteReader As System.IO.BinaryReader = New
System.IO.BinaryReader(fs)

Dim byteArray() As Byte
ReDim byteArray(128)

byteArray = vByteReader.ReadBytes(128)

....

from here, i will check the array byteArray(i) for the different
cases.

thanks.

"The Grim Reaper" <gr*********@btopenworld.com> wrote in message news:<cb**********@hercules.btinternet.com>...
Use a BinaryReader, and read in say 128 bytes at a time - vByteArray =
vBinReader.ReadBytes(128)
Then check the array for bytes of value 10 or 13 - or as Mythran says,
combinations of 10, 13, 10 & 13 or 13 & 10.
_____________________________
The Grim Reaper

"Mythran" <ki********@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP11.phx.gbl...
Open the file and instead of using readline, just use read passing 1 as

length.
Compare that single character as a vbCr or vbLf. If you *must* check for

vbCrLf,
you should watch out because sometimes they are backwards, vbLf & vbCr.

Hope this helps,
Mythran

"Andrew" <ne*************@yahoo.com> wrote in message
news:7d**************************@posting.google.c om...
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 length.
In my application, I would like to open one of these text files and
check to see if it contains crlf's before proceeding in my code. I
tried using the streamreader, but readline() cancels out with a memory
error because it thinks the ENTIRE file is first record since there
are no crlf's. I have also tried FSO, but I get a server timeout.

Is there any easy way to check for crlf's with files like this?

Thanks!


Nov 20 '05 #4

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

Similar topics

3
by: Mark | last post by:
I'm working with ASCII data files provided by data vendors in a standard format. These files contains lots of various pieces of information for each reporting entity in the file. Currently I...
2
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an...
3
by: Edward Grosso via .NET 247 | last post by:
Hi to all the dotnet community, I'm actually trying to figure out how can I save a Recordset to an ASCII file with custom field separators, in a fast way, without loops. Perhaps there is some way...
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...
9
by: olson_ord | last post by:
Hi, My ascii file is not exactly a comma separated file. The following is a small but complete example of such a file. (This is the ISCAS circuit file format that I need to read in.) ...
6
by: SandyMan | last post by:
Hi, I am able to open a binary file for reading but can someone tell me as how to go about converting a Binary file to ASCII file using C. Thanks In Advance SandyMan
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
0
by: lanesbalik | last post by:
hi all, right now i'm trying to migrate from db2 running under linux to mysql v5.1. i manage to export out the db2 structure & data into a del (ascii) file. but when i try to load the data...
10
by: Kristapins | last post by:
Hello! If anyone can help me... I have ASCII file with statistic data, and need to read only one line from it, how can I indicate, which line I want to read and then print in another file...??? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: 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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.