Hi All,
I have been trying to use ADODB to open a CSV file (only coma separation, no double quotes around each field).
I use the following connection string
However the header row does not contain all the columns and using _ArrayDisplay. Columns 0, 3, 4, 5, 6, 7, 8, 9 and 12 are always empty.
However, If I get 2 rows, all the data are present but the header is still missing some columns.
Also, if I say to skip the header row, then there is no data loss.
The following is a sample of the file that produces the error:
I thought there must be something wrong with CSV file. I then loaded it into Excel 2003 and saved as .XLS. Using the appropriate connection strings etc, all the header columns are present.
I then created a dummy CSV file as follows:
And when running with the above code, The BBB header is always empty.
I then created another dummy CSV file as follows:
Now, all the header columns are empty.
Anyone know what is going on?
BTW, this was tested on a computer without Office installed and a computer with Office 2010 installed with the same effect.
Cheers,
Vlad
I have been trying to use ADODB to open a CSV file (only coma separation, no double quotes around each field).
I use the following connection string
$connStr = 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=' & $csvPath & _ ';Extended Properties="Text;HDR=No;FMT=Delimited(,);IMEX=1";' $objConn.Open($connStr) $objRS.Open("Select * From " & $csvFile, $objConn, $AD_OPEN_STATIC, $AD_LOCK_OPTIMISTIC, $AD_CMD_TEXT) $hearderRow = $objRS.GetRows(1)
However the header row does not contain all the columns and using _ArrayDisplay. Columns 0, 3, 4, 5, 6, 7, 8, 9 and 12 are always empty.
However, If I get 2 rows, all the data are present but the header is still missing some columns.
Also, if I say to skip the header row, then there is no data loss.
The following is a sample of the file that produces the error:
TermNumber,DNSName,DNSDomain,DNSClientIP,SrvClientIP,SrvClientMask,SrvIP,SrvMask,SiteID,SiteNumber,SiteEC,DNSCltName,ClientIP,SitePassword 1,myServer,site1.xxx.yyy.zz,10.10.10.10,10.10.10.11,255.255.255.255,10.10.11.11,255.255.255.255,1,2,883242,myClient,10.10.10.12,MyPassword
I thought there must be something wrong with CSV file. I then loaded it into Excel 2003 and saved as .XLS. Using the appropriate connection strings etc, all the header columns are present.
I then created a dummy CSV file as follows:
AAA,BBB,CCC,DD,EEEE,FF,54y,6y75,et3,f34 123,345,dfgsd,56g,dfgh,53gs,t34g,rf23,sd5t,f34 fgd,45,fgd,6y,r3g,34,f23,as4,t34,f4
And when running with the above code, The BBB header is always empty.
I then created another dummy CSV file as follows:
AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III,JJJ,KKK,LLL,MMM 111,222,333,444,555,666,777,888,999,000,111,222,333 222,333,444,555,666,777,888,999,000,111,222,333,444
Now, all the header columns are empty.
Anyone know what is going on?
BTW, this was tested on a computer without Office installed and a computer with Office 2010 installed with the same effect.
Cheers,
Vlad