Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting one loooooong record into several fixed length records

Status
Not open for further replies.

jewilson2

Technical User
Feb 7, 2002
71
US
Hello all.

I have a file with several records (all of which are 94 characters in length). The problem is that there are no carriage returns/line feeds in the file...sooooo when you view the file (in a text editor) it appears as one long record.

Is there a piece of code that could import this file, insert a carriage return line feed behind every 94th character, then output it to a table/file as several, 94 character records?

Thanks in advance,
JW
 
Hallo,

You could write one yourself...

Have you tried opening the file as a Binary file and reading a String*94 type variable from it?

- Frink
 
I have not tried that(not really sure I understand your suggestion).

I'm basically looking for the best way to accomplish this (user friendly) because it will need to be done to the file every week as part of an interface.

Thanks,
JW
 
Hallo,

Why don't you just use the standard access import facility?

File->Get External Data->Import

Set it to import a single fixed with field.

- Frink
 
Hallo,

Why don't you just use the standard access import facility?

File->Get External Data->Import

Set it to import a single fixed with field.


Alternatively you can write some code and use the Get statement:
Code:
Dim intFileNo as Integer
Dim strRecord as String * 94
intFileNo = FreeFile
' Open sample file for random access.
Open "TESTFILE" For Random As #intFileNo Len = Len(strRecord)
' Read the sample file using the Get statement.
Get #intFileNo , , strRecord 	' Read first record.
Close #intFileNo 	' Close file.

Summat like that (taken from Access help and hacked a bit)
- Frink
 
I was thinking that would simply import the first 94 characters and forget the rest. Can you make it import the first 94 characters as the first record, the second 94 characters as the second record, etc etc until it reaches EOF?
 
Hallo,

You might be right. Have you tried it?

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top