Koby
|
Posted: 04/23/2004, 5:36 AM |
|
Hello,
I have a problem! I'm trying to pull data from three different csv files into Access, but the problem is, that the three files have different delimiters! I tried it with a ';' as delimiter and this worked perfect, but I have for example a file with a pipe delimiter, how can I read this file?
Here is my code:
<%
'Making a connection with the database
set objConn= Server.CreateObject("ADODB.Connection")
strDBPath = Server.MapPath("./test.mdb")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
' Path of the CSV file
Dim csv_path
csv_path = Server.MapPath("./") & "\"
'Use the next 7 lines of code to delete a table then insert records
'Make sure 1st line of csv file has field names that match access database
'On Error Resume Next ' IGNORE error if tabimport does not exist
'SQL = "DROP TABLE tabImport"
'objConn.Execute SQL
'On Error GoTo 0 ' turn off the ignoring of errors!
' SQL String for inserting CSV data into the Database
SQL = "SELECT * INTO test FROM [test.csv] IN """ & csv_path & """ ""TEXT;"""
' SQL String for inserting CSV data into the Database
'SQL = "INSERT INTO test SELECT * FROM [test.csv] IN """ & csv_path & """ ""TEXT;"""
'Executing the SQL Statement
objConn.Execute SQL
'Closing down the connection
objConn.Close
Set objConn = Nothing
Response.write "finished the import"
%>
It would really appreciate if anybody could help me!
Thanks in advance!
Best Regards
Koby
|
|
|
peterr
Posts: 5971
|
Posted: 04/23/2004, 1:13 PM |
|
I found possible solutions here: http://groups.google.com/groups?threadm=1dpqqu8f86u4fp7...04ax.com&rnum=1 http://msdn.microsoft.com/library/default.asp?url=/libr...ma_ini_file.asp
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Koby
|
Posted: 04/27/2004, 9:19 AM |
|
Hello Peterr,
thanks so much for your help, I had never worked with an ini file, this option is perfect!
Here is the code I used within the ini file:
[file.txt]
Format=TabDelimited
ColNameHeader=True
[file2.txt
Format=Delimited(|)]
ColNameHeader=True
Thanks again!
Regards
Koby
|
|
|
|