PDA

View Full Version : Import text file into access table



rahela_r
04-08-2006, 05:00 AM
on access 2003 is it possible to import a text file (fixed or delimited)
and omit certain rows.
The file in question contains headers on each page and underlines ect
which i do not want to get into the table

Thanks
rahela_r

:hug:

Norie
04-08-2006, 07:08 AM
Why not just import the whole file and then use a delete query to remove the header rows?

OBP
04-08-2006, 08:11 AM
The best method is to import the text file in to Excel and then sort the whole table. Which brings all of the headings to one place and you can then delete them prior to importing in to Access.

rahela_r
04-15-2006, 03:51 AM
The problem of import is
a. there are more then 65,000 records so it cannot be done via excel
b. i do want to know if there is a way to import text into access, like excel, meaning, certain caracters, within a record (line of text of the
ascii file) not to import into access, and also certain rows like header
and such (rows with certain caracters that can be pre defined) not
to enter at all

Thanks

OBP
04-15-2006, 04:22 AM
This is the Access help

Important Before you import (http://vbaexpress.com/forum/#) or link data from a delimited text file (http://vbaexpress.com/forum/#) or fixed-width text file (http://vbaexpress.com/forum/#), make sure that the file has the same type of data in each field and the same fields in every row.

Open a database, or switch to the Database window (http://vbaexpress.com/forum/#) for the open database.
Do one of the following:
To import data, on the File menu, point to Get External Data, and then click Import.
To link data, on the File menu, point to Get External Data, and then click Link Tables.
In the Import (or Link) dialog box, in the Files of type box, select Text Files (*.txt; *.csv; *.tab; *asc).
Click the arrow to the right of the Look in box, select the drive and folder where the file is located, and then double-click its icon.
Follow the directions in the Import Text Wizard dialog boxes. Click Advanced to create or use an import/export specification (http://vbaexpress.com/forum/#). To cancel importing, press CTRL+BREAK.
Notes

You can append the data to an existing table as long as the first row of your text file matches the table's field names.
If all the records in a fixed-width text file are the same length, an embedded row separator (such as a carriage return and a linefeed) in the middle of a record will not cause unexpected results. However, if the records aren't all the same length, Microsoft Access will treat the embedded row separator as the end of the record.

rahela_r
05-02-2006, 03:03 AM
The problem of import is
a. there are more then 65,000 records so it cannot be done via excel
b. i do want to know if there is a way to import text into access, like excel, meaning, certain caracters, within a record (line of text of the
ascii file) not to import into access, and also certain rows like header
and such (rows with certain caracters that can be pre defined) not
to enter at all

Thanks

Well, sorry that I was not clear
What I mean is to read it into access via vba
that is, i have x strings for the first field, y strings for the second field
a number for the field ect
what is the exact syntact to get the data into one record
Thanks for all the people who try to help
rahela

stanl
05-02-2006, 03:31 AM
I agree with Norie that you might want to import all rows then run a Delete query. I've always done it with ADO and the Jet 4.0 text driver. It requires creating a schema.ini entry. If you would care to post a sample of your text file I can explain further. Stan