473,327 Members | 2,112 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,327 software developers and data experts.

How to read "binary" file sequentially?

1
Hi!! I have a question here where I used :
Expand|Select|Wrap|Line Numbers
  1. Open sourceDir & sourceFile For Input As af
  2. Do While Not EOF(af)
  3.  
  4.     Line Input #af, textline
  5.  
  6.     If Trim(textline) Like "fruits" Then
  7.         list_start = True
  8.     End If
  9.  
  10. Loop      'loop while not end of file
  11. Close #af 'close file
but the problem is that the whole file is read into textline instead of line by line, how can i change the file so that I'll be able to capture line by line?
(Opening the file using textpad and notepad produces different format, textpad will open it with line by line while notepad shows the whole file in a string) Thx a lot!!!!
Mar 28 '07 #1
2 1726
Dököll
2,364 Expert 2GB
Hey there buzzy!

There are a number of posts here on this very subject, some posted by me. Please search a little deeper, see what pops up. Try adding strGetWords to your search if you need to see something I have posted. I must caution, and this something I became aware of through hours of research, when you are reading from a text file, you will likely be reading a word within a word, whereby rain is found in train:-) Of course, if you are after a different medium, you should be ok with the code as is...

Good luck!

Dököll
Mar 28 '07 #2
Killer42
8,435 Expert 8TB
Your file has the wrong delimiter characters at the end of each line. In the DOS/Windows world, it should have two characters - CR (Carriage Return, ASCII code 13) and LF (Line Feed, ASCII code 10). Generally just referred to as CRLF. It probably has just one or the other (CR or LF). This is common with files coming from other operating systems, such as Unix.

One quick and relatively simple way to correct the file is to open it in MS Word and save it again as plain text. Word will (probably) put in the proper delimiters.
Mar 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Phil Powell | last post by:
I have a PHP script that would read in a binary file and display it as if it were <img src>, how would you do that w/o changing the header's MIME type? The entire file does not need to be changed....
3
by: DrewM | last post by:
I'm using ASP to generate an RTF (rich text) file, via the FSO. No problems with text, but when it comes to inserting images, the files have to be embedded as either binary or hex. Try as I...
2
by: Pete | last post by:
Hi Could someone kindly help with the C# equivilent of the following 4 lines of C code. I'm *really* struggling with this. ( Colours.dat contains 300 RGB values ) COLORREF Colours;
8
by: S Shulman | last post by:
Hi All I need to read a file to an array of bytes (any type of file) I tried using FileStream and BinaryReader but it doesn't seem to work Thank you, Shmuel
1
by: Quinn | last post by:
Hi all, I have some binary files in the following format: text line 1 text line 2 .... text line N end of text single in binary 1 single in binary 2 single N EOF
4
by: Matrixinline | last post by:
Hi All Here is my problem I am using a Unicode project and I tried to read the File like sPath = LPCTSTR; FILE* oFp = _tfopen(sPath,L"r"); while(!feof(oFp))
2
by: kowndinya | last post by:
Hello, i want to read values from a binary file in VisualBasic 6.0 Initially i want to read only header of this binary file. I know this structure for this header. It is 100 bytes long and...
2
by: tulasisridhar | last post by:
Hi All, I have binary file created in Unix I now need to read it using VB.net and doo some procesing. There is some conversion between bigendian and little endians. I know the structure...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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: 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: 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.