R
Ross Cox
I'm trying to write code that will import a text delimited file with unknown
# of fields and other then comma for delimiter. The input code is:
infile = CurrentProject.path & "\tmpfile.csv"
DoCmd.TransferText acImportDelim, , "tblImport", infile,
Me.chkHeader
The schema.ini file is in the same directory as tmpfile.csv, and is
customized with whatever the user's delimiter happens to be (and
ColNameHeader set TRUE or FALSE depending on me.chkheader). Like:
[tmpfile.csv]
Format=Delimited(|)
ColNameHeader = TRUE
MaxScanRows = 0
CharacterSet = ANSI
This code works perfectly if I use Format=Delimited(,), but does not seem to
work with any other delimiter. I tried * and | and others. I end up with
just a couple of fields input, with the data not seperated where the
delimiter is. A typical field in a record ends up looking like this:
DL52579106|Jankowsky|Ann|Maureen McKee Eidson?|||||||Ebbtides Nite-Lite
UD|03/04/1994|Emmett & Ann Atkinson|Levi Docker of Heatherhill|Ebbtide Get
Real|Australian Shepherd|Dog
I tried CharacterSet=OEM with same results. The challenge here is that I'm
inputting data from a user's file with the number of fields and delimeter
are variables (and if first row is header or not). The data may contain
commas. I have a routine to strip out the single and double quotes before
the import runs.
Any thoughts?
# of fields and other then comma for delimiter. The input code is:
infile = CurrentProject.path & "\tmpfile.csv"
DoCmd.TransferText acImportDelim, , "tblImport", infile,
Me.chkHeader
The schema.ini file is in the same directory as tmpfile.csv, and is
customized with whatever the user's delimiter happens to be (and
ColNameHeader set TRUE or FALSE depending on me.chkheader). Like:
[tmpfile.csv]
Format=Delimited(|)
ColNameHeader = TRUE
MaxScanRows = 0
CharacterSet = ANSI
This code works perfectly if I use Format=Delimited(,), but does not seem to
work with any other delimiter. I tried * and | and others. I end up with
just a couple of fields input, with the data not seperated where the
delimiter is. A typical field in a record ends up looking like this:
DL52579106|Jankowsky|Ann|Maureen McKee Eidson?|||||||Ebbtides Nite-Lite
UD|03/04/1994|Emmett & Ann Atkinson|Levi Docker of Heatherhill|Ebbtide Get
Real|Australian Shepherd|Dog
I tried CharacterSet=OEM with same results. The challenge here is that I'm
inputting data from a user's file with the number of fields and delimeter
are variables (and if first row is header or not). The data may contain
commas. I have a routine to strip out the single and double quotes before
the import runs.
Any thoughts?