Importing data from txt ignoring headers and footers

G

Guest

I need some help importing data from text files into access. I've got a text
file that is fixed-width text but the text file has multiple "pages" (though
no formal page breaks) of text only distinguished in the text file by a few
lines of header text and a few lines of footer text. I can write VBA to
import the text and arbitrarily set the fixed width to match up with the text
files I want to import though I imagine this isn't the most elegant way to do
this. I can't figure out how to have the system ignore the rows that contain
headers or footers. Anyone have a suggestion of how to do this? I'd also
love suggestions about how to import the rest of the data more elegantly.
Here's how the headers and footers look:

REPORT
Last Name First Name # Call Date Extension
Seat #
_____________________________________________________________________








_____________________________________________________________________
{district/location} Div: {division} File: {filenumber}
Total Count: {number of records} {Date Time} Page:
{pagenumber}
 
G

Guest

Thanks for the advice, Steve. I should have been more specific. I've
actually been using TransferText to bootstrap the data into the table. Is
there a way to use TransferText to bring in the data without those headers
and footers?

Right now I'm being lazy and using the SpecificationName function to grab
the specs for the fixed width text file on import from Access but I can put
it into a scheme.ini file if I need to... I'm still unclear on how to skip
the headers and footers. Here's my code right now (as simplistic as it is):

DoCmd.TransferText acImportFixed, "test1", "tblImport1",
"c:\Texts\test1.txt"

The header always starts with the word "REPORT" and the header always ends
with a line. The footer always starts with a line and ends with the page
number. Because the info on these lines is predictable I figured there must
be a way to grab it automatically but if there isn't I suppose I can manually
import the information. I'm just looking for some way to make this work.
Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top