Hehe LMAO.
Guess what, I did exactly the same thing -was good coding practice anyhow
and importantly was to go through the jobserve.csv file (any guesses why?!)
Then one day I stumbled upon some code and thought "you plum!". This
following code came from the MCAD/ MCSD Developing Windows Based
Applications book from MSPRESS (dont buy it though the dual vb.net/ c#.net
training is a pain in the proverbial). The most important line is the very
last one in the listing.
// This example assumes the existence of a text file named myFile.txt
// that contains an undetermined number of rows with seven entries
// in each row. Creates a new DataSet
DataSet myDataSet = new DataSet();
// Creates a new DataTable and adds it to the Tables collection
DataTable aTable = new DataTable("Tabl e 1");
myDataSet.Table s.Add("Table 1");
// Creates and names seven columns and adds them to Table 1
DataColumn aColumn;
for (int counter = 0; counter < 7; counter ++)
{
aColumn = new DataColumn("Col umn " + counter.ToStrin g());
myDataSet.Table s["Table 1"].Columns.Add(aC olumn);
}
// Creates the StreamReader to read the file and a string variable to
// hold the output of the StreamReader
System.IO.Strea mReader myReader = new
System.IO.Strea mReader("C:\\my File.txt");
string myString;
// Checks to see if the Reader has reached the end of the stream
while (myReader.Peek( ) != –1)
{
// Reads a line of data from the text file
myString = myReader.ReadLi ne();
// Uses the String.Split method to create an array of strings that
// represents each entry in the line. That array is then added as
// a new DataRow to Table 1
myDataSet.Table s["Table 1"].
Rows.Add(myStri ng.Split(char.P arse(",")));
}
--
--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Cat" <lo***********@ yahoo.co.uk> wrote in message
news:eC******** ******@tk2msftn gp13.phx.gbl...
I don't understand why there's no class included in the libraries for
reading CSV files.. I've created my own CSV reader class which reads a CSV
file, generates a report and returns records etc. Although I'm proud of
having tackled the problem and produced code that works I worry that I
could have saved a lot of time if I could have just found that class in the
library which I'm convinced must work.
Does anyone have an explanation as to why there's no such class?
Cat