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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to import a file with lines of different format?

Status
Not open for further replies.

evgeniosc

IS-IT--Management
Oct 5, 2002
75
CY
I want to import a text file (fixed column length) with lines of multiple formats.
This file has one header line that has the number of records of each format.
e.g

Header line: 10 11 12
This header line says to us that follow 10 lines of format A, 11 lines of format B and 12 lines of format C

Follows 10 lines (2-11) have the format A
Follows 11 lines (12-22) have the format B
Follows 12 lines (23-32) have the format C

Is there any sample code that imports such a file?

I already though of an algorithm that does this but I thought that someone else might already has programmed something like this.

Algorithm
---------
Read the first line and retrieve the number of records of each format
Read the next 10 lines (2-11) and put them in a file A.txt
Read the next 11 lines (12-22) and put them in a file B.txt
Read the next 12 lines (23-32) and put them in a file C.txt

Use Microsoft Access to import the 3 files in seperate tables based on different import specification

 
You algorithm looks fair to me.

I already though of an algorithm that does this but I thought that someone else might already has programmed something like this.

To be honest, even if someone *had* done this before, the spirit of these forums would mean that they would tend to post guidance rather than their entire code ... although you might get lucky if someone's feeling generous.

Use Microsoft Access to import the 3 files in seperate tables based on different import specification

... or you could forget about writing the 3 files and use JDBC to put the data directly into the Access tables.

Tim
 
Possibly Chrissie, but I haven't got any existing code for this, I'm afraid.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top