PC Review


Reply
Thread Tools Rate Thread

Delimiter for csv and text file using ADO

 
 
Jean-Yves
Guest
Posts: n/a
 
      20th Dec 2006
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 With Quote
 
 
 
 
Jean-Yves
Guest
Posts: n/a
 
      22nd Dec 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Text file with Strange Delimiter Jason Microsoft Access External Data 1 20th Feb 2009 09:02 PM
Importing Text File with Strange Delimiter Jason Microsoft Access 4 19th Feb 2009 09:12 PM
Importing text file without end-of-line delimiter? ker_01 Microsoft Excel Programming 8 8th Jul 2008 04:13 PM
Reset Delimiter when opening text file =?Utf-8?B?S0FN?= Microsoft Excel Programming 8 8th Sep 2006 01:18 PM
Need Help Importing Text File Using Two or More Spaces as the Delimiter jessiright77@gmail.com Microsoft Excel Programming 11 13th Jun 2006 02:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:11 PM.