MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading trailing spaces in csv file

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet
Author Message
NInad



Joined: 06 Dec 2007
Posts: 1

PostPosted: Thu Dec 06, 2007 6:08 pm    Post subject: Reading trailing spaces in csv file Reply with quote

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?

Archived from group: microsoft>public>dotnet>framework>odbcnet
Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
reading dbf tables I have an interesting problem reading data from a dbf table I can create a dbf table in excel, save it then use odbc in .net to read it - ok. I can read the same table in another (3rd party) app ok. If I change data in the table using the 3rd party app th

Reading dBase WVARCHAR I'm working with a DBase database and I'm having a hard time reading some of the fields use the When reading it as a String I get: TestCase failed: : Specified cast is not valid. at Syst

OLE DB provider for reading DBF files using ASP.NET I am trying to read a DBF file using ASP.NET, I have spent hours trying to get the correct connection string. Is there anyone out there that has successfully connected a dbase III file with a ASP.NET page?? If ( readDBFFile == TRUE ) then read on; else d

Reading SQL Script from Stored Procedure Hi Everybody, Good day! Are there any direct methods in dotnet for reading the SQL script from a database for a particular stored procedure! Note: I'm aware of using SP_HELPTEXT in a DataReader! Thanks in advance. From: Pr

Reading FoxPro Date field frpm ODBC Ok, what is the trick!!! I am using C# to read a FoxPro DBF file. I do the following: Private DataSet dbfFile) { DataSet ds = new DataSet(); string Sql; int dbfNameStart = string dbfTableName =
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group