简体   繁体   中英

query CSV file, table name with period

I made a function to query a CSV file. It all works just fine... but, when a header contains a period it generates an error. (This is in UFT/QTP).

'Create ADODB connection object
Set objConnection = CreateObject("ADODB.Connection")


'Create Recordsetobject
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Provider  = "Microsoft.Jet.OLEDB.4.0"
objConnection.ConnectionString = "Data Source=" & strCSVpath & ";" & "Extended Properties=""text;HDR=Yes;FMT=Delimited"""
objConnection.Open

'Execute the query
objRecordSet.open sqlQuery, objConnection 

value = objRecordSet.fields.item(0)                 

objRecordSet.Close
objConnection.Close
Set objConnection = Nothing
Set objRecordSet = Nothing

The CSV contains something like:

head1;head2;hea.d3;
val1;val2;val3;

Reading header 3 (hea.d3) gives an error. Tried:

"Select hea.d3  from [test.csv] "
"Select [hea.d3]  from [test.csv] "
"Select (hea.d3)  from [test.csv] "

Non works... can anyone give me advice?

Cheers, Giel

Solution:

select [hea#d3] from [test.csv] 

thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM