Read CSV file into DataSet

50 views
Skip to first unread message

Hugh

unread,
May 3, 2012, 9:33:23 AM5/3/12
to CSVChat
Hi,

I use csvReader to read a csv file into a dataset:

DataSet.Clear()
Using csvData = New CsvReader(filename)
DataSet.SourceData.Merge(csvData.ReadToEnd())
End Using

Is there any easy way to put an empty string as record value if there
is nothing in corresponding csv file? I don't want a Null value of
any record in the DataSet.

Thanks very much in advance for your help.

Hugh

shriop

unread,
May 7, 2012, 9:55:14 AM5/7/12
to csv...@googlegroups.com
I can only come up with two options so far, and you're probably not going to like either of them because they're a little verbose. The first would be to write out the logic that I have inside ReadToEnd and check for nulls and if found change them to an empty string before putting them into the table. The second would be to loop over the table after it has been loaded and check every column in every row to see if it's a null and if it is, change it to an empty string.

Bruce Dunwiddie

Lu, Hugh

unread,
May 7, 2012, 10:15:29 AM5/7/12
to csv...@googlegroups.com

Hi Bruce,

 

That was pretty much what I was thinking.  I did not want to overlook at any possible easy solution.  Thanks very much for your response.

 

Hugh Lu

Bio-Informatics & Lab Systems

Pioneer Hi-Bred International

A DuPont Company

7200 NW 62 Ave.

Building # 36

Johnston, IA 50131

Phone: 515-535-4232

Fax: 515-535-3346

--
You received this message because you are subscribed to the Google Groups "CSVChat" group.
To view this discussion on the web visit https://groups.google.com/d/msg/csvchat/-/bux7uV4hUqAJ.
To post to this group, send email to csv...@googlegroups.com.
To unsubscribe from this group, send email to csvchat+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/csvchat?hl=en.

This communication is for use by the intended recipient and contains
information that may be Privileged, confidential or copyrighted under
applicable law. If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited. Please notify the sender by
return e-mail and delete this e-mail from your system. Unless explicitly
and conspicuously designated as "E-Contract Intended", this e-mail does
not constitute a contract offer, a contract amendment, or an acceptance
of a contract offer. This e-mail does not constitute a consent to the
use of sender's contact information for direct marketing purposes or for
transfers of data to third parties.

Francais Deutsch Italiano  Espanol  Portugues  Japanese  Chinese  Korean

           http://www.DuPont.com/corp/email_disclaimer.html
Reply all
Reply to author
Forward
0 new messages