Hi folks,
New C# programmer here.
I am reading some CSV data from a file into an ArrayList. I want to get the
data from the ArrayList into a 2-dimensional array. I see a few references to
..Split, but I'm not sure that's what I need.
So, basically, what I have loaded into the ArrayList is:
"a, 1"
"b, 2"
"c, 3"
And what I want is a 2-d array with
array[0,0] == "a"
array[0,1] == "1"
array[1,0] == "b" etc.
Here's my code so far:
static void Main(string[] args)
{
//open streamreader to read in data file
StreamReader objReader = new StreamReader("c:\\data.csv");
string sLine="";
//read file in as an arraylist
ArrayList arrText = new ArrayList();
//read until end of file
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
//add each line of text file in
arrText.Add(sLine);
}
objReader.Close();
//create the 2-d array
string [ , ] mydata;
//parse out the columns
//mystery code goes here
You guys are great. Thanks in advance for any help/advice.
Dave