Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV files in C#

Status
Not open for further replies.

welshboy202010

Programmer
Mar 8, 2007
6
GB
Hi guys,

I'm writing a program that needs to parse a csv file into a c# program.

I've written the customer class, with the intention of creating customer objects, which will store the data of the csv file.

The bits I'm confused about is teh loading of the csv file and putting the data in it to the appropriate set methods in the customer class.

Once I've done that, it'll be a small matter of getting the GUI working, that much I can do.

The book i have on C# is very vague on file IO to say the least. Any help would be greatly appreciated.

welshboy
 
this is a good place to start google results

personall I would only read a csv, not write a csv. instead i would write to a database or xml file.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Check if there is an OLE provider for .csv files. I know there is an ODBC provider.

I would use either of these to fill a data table with the info from your file.

Hope this helps,

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
You misunderstand me,

I want to load a CSV not write one,

I have a customer class which has sets and gets for the usual bumf, and I want to put the data from the CSV into a collection of customers, so I can display it on a GUI.

Sorry for the confusion.

Any help would be awesome

welshboy
 
I don't think I misunderstood you at all.

You could read in your text file as a text stream and parse it in your app, but why not use ADO.net to bring it into a data table (or dataset, etc... where all the parsing will have been done for you)?

Here is an article on reading in a text file using ADO.net


Hope this helps,

Alex

[small]----signature below----[/small]
I don't do any programming whatsoever

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top