[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Reading trailing spaces in csv file

NInad

12/6/2007 9:08:00 PM

I am reading a .csv file using ODBC driver in .NET

System.Data.Odbc.OdbcConnection conn;
System.Data.Odbc.OdbcDataAdapter da;
DataTable dt = new DataTable();

string connectionString = @"Driver={Microsoft Text Driver (*.txt;
*.csv)};Dbq=c:\Work;FMT=CSVDelimited;";
conn = new System.Data.Odbc.OdbcConnection(connectionString);

da = new System.Data.Odbc.OdbcDataAdapter("select * from data.csv", conn);
da.Fill(dt);

The input folder where the file exists has a Schema.ini which the following
content
[data.csv]
ColNameHeader=False
Format=CSVDelimited
CharacterSet=ANSI

the input file (data.csv) looks like this

" 1234D3","The faculty ","complete"
" 1234D4","Student ","complete"
" 1234D5","Head ","complete"

After the code executes the data table holds 3 rows and 3 columns
for row 1 and column 1 the data holding the leading spaces and comes up as "
1234D3"
But the row 1 and column 2 the data does not hold the trailing spaces comes
up as "The faculty" and not "The faculty "

Same for all 3 rows.

When i debug the application as where the trailing spaces are lost. I came
to know that it is lost in the OdbcDataReader itself.

can someone help to point out how to get the trailing spaces?