Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Delimiter for csv and text file using ADO

Hello,

What I found so far did not answer my question.
On 2 pc's with "similar" regional setting (we tried to get), a query return
only one column or all
depending if the delimiter is a comma (,) or semi-colon(;)
Any experience with this ?

format of csf file
head1;head2
sssss;gggggg
sdfaf;asdfdfdf
.....

Sub test()
Dim strConnection, conn, rs, strSQL

strConnection = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & ThisWorkbook.Path &
";Extensions=asc,csv,tab,txt;Persist Security Info=False"
Set conn = CreateObject("ADODB.Connection")
conn.Open strConnection
Set rs = CreateObject("ADODB.recordset")
strSQL = "SELECT * FROM myFile.csv"
rs.Open strSQL, conn

'Debug.Print rs.Fields(0).Name & " " & rs.Fields(1).Name
While Not rs.EOF
Debug.Print rs.Fields("nom").Value
Debug.Print rs.Fields(1).Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub

Regards
JY Tfelt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Delimiter for csv and text file using ADO

After searching (a long time),
The default delimiter , as specified in the regional settings panel is kept.
A schema.ini file as to be created in the same directory where the text/csv
file is located.
Regards
JY

"Jean-Yves" wrote in message
...
Hello,

What I found so far did not answer my question.
On 2 pc's with "similar" regional setting (we tried to get), a query
return only one column or all
depending if the delimiter is a comma (,) or semi-colon(;)
Any experience with this ?

format of csf file
head1;head2
sssss;gggggg
sdfaf;asdfdfdf
....

Sub test()
Dim strConnection, conn, rs, strSQL

strConnection = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & ThisWorkbook.Path &
";Extensions=asc,csv,tab,txt;Persist Security Info=False"
Set conn = CreateObject("ADODB.Connection")
conn.Open strConnection
Set rs = CreateObject("ADODB.recordset")
strSQL = "SELECT * FROM myFile.csv"
rs.Open strSQL, conn

'Debug.Print rs.Fields(0).Name & " " & rs.Fields(1).Name
While Not rs.EOF
Debug.Print rs.Fields("nom").Value
Debug.Print rs.Fields(1).Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub

Regards
JY Tfelt



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reset Delimiter when opening text file KAM Excel Programming 8 September 8th 06 01:18 PM
Need Help Importing Text File Using Two or More Spaces as the Delimiter [email protected] Excel Discussion (Misc queries) 11 June 13th 06 02:08 AM
Need Help Importing Text File Using Two or More Spaces as the Delimiter [email protected] Excel Programming 11 June 13th 06 02:08 AM
export excel file as csv with text delimiter of " John Excel Discussion (Misc queries) 2 May 12th 05 05:50 PM
Import/Export Text File Tab Delimiter Cool Sport Excel Programming 3 December 20th 04 12:22 PM


All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"