I tried to import a CSV file containing 2 columns (e.g. Date and Price) and print it on the console. But on my console, numbers are not ordered by columns. They are one next to another.
First Question: how can I print it on the console correctly?
Second Question: can I combine these two arrays, create a matrix and print the matrix on the console? Is it easier?
Here is my code:
using system.IO;
var reader=new StreamReader(File.OpenRead(@"filename.csv");
list<string> listA=new list<string>();
list<string> listB=new list<string>();
while (!Reader.EndofStream)
{
var Line=reader.ReadLine();
var valuesline.split(';');
listA.Add(values[0]);
listB.Add(values[1]);
}
console.WriteLine("Column1:");
foreah (var Element in listA)
{
console.write(Element);
console.WriteLine("Column2:");
}
foreah (var Element in listB);
{
console.write(Element);
string[] S= listA.toArray;
string[] o=listB.toArray;
}
foreach (var Element in listA);a semi colon after the parenthesis will end the statement (it valid to do that) and not loop to the next line(s). Surely you mean it without the semi colon?foreach (var Element in listA)