• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

VB Command for seq files to read to end of record

I am trying to read a flat file out of a VB Access 2007 sub.  I want to be able to read to the end of line and then start parsing the file.

Is there a command in VB for Access 2007 that will allow me to read to the end of line or CR LF characters?

Not all the lines are the same length and so that presents a problem.

Thank you.
0
rpaaep
Asked:
rpaaep
  • 5
  • 4
1 Solution
 
Rey Obrero (Capricorn1)Commented:
what is the format of the flat file?
if it is text,

dim s
open "c:\myfiel.txt" for input as #1
do until eof(1)
 line input #1, s
 debug.print s

loop
close #1
0
 
rpaaepAuthor Commented:
Hi,

When I did this I got out of string space error message.  It is a text record (csv).

The first record's length is 11657 + 0A(line feed character)  There is no 0D0A for each record as in DOS.  This came from a gov't mainframe I am think or some sort of Unix based box.

The data records are around 1190 + 0A depending on how much data is in the file.

It appears the code above is trying to read the whole text file due to no 0D0A in the record.  In other words, it does not see the 0A as a line terminator.  This is my guess.

The lcLine = INPUT(1200, #3) reads past the 0A and starts to pick up the next record.  

What I need is a way for it to find or recognize the 0A as the end of record so I can process one record at a time.

Any thoughts on this?



0
 
Rey Obrero (Capricorn1)Commented:
can you upload a sample file? perhaps read it as hex
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
rpaaepAuthor Commented:
The file it is part of is 3gigs so not sure if that would work.

I don't know how to read it as hex but I could read it one character at a time until the 0A is reached then process the record, etc.

If you could give some direction of how to read it as hex or recognize the hex 0A that would be great.
0
 
Rey Obrero (Capricorn1)Commented:
do a search in the web for hex editor program called xv132
0
 
rpaaepAuthor Commented:
I have that one and found the value through looking at the hex editor at the file.

I was just wondering it there was a way to have the input function or some other function read up to the point of 0A.

What I am trying to do is automate this so it can simply be read, the record parsed and then loaded into a table.

0
 
Rey Obrero (Capricorn1)Commented:
0
 
rpaaepAuthor Commented:
What I noticed in the referred solution was a print command with the ";" at the end to not print the CRLF,

When I tried it with the Input command it gave a compiler error.

Any other ideas?
0
 
rpaaepAuthor Commented:
It was accurate for what was said.  What it did was put me in the right direction.  I ended up opening it as binary and then read a character at a time and checked for Chr$(10) for end of record.  That fully took care of the problem.

Thank you to cparicorn1.

Robert
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now