简体   繁体   English

查询CSV文件,带句点的表名

[英]query CSV file, table name with period

I made a function to query a CSV file. 我做了一个查询CSV文件的功能。 It all works just fine... but, when a header contains a period it generates an error. 一切都很好...但是,如果标头包含句点,则会产生错误。 (This is in UFT/QTP). (这在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: CSV包含以下内容:

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

Reading header 3 (hea.d3) gives an error. 读取标头3(hea.d3)会出错。 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. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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