1

My project is converting CSV file into table form. I'm ready with parse CSV file ( split ; from file) and with table generating. Now i'm just need to assemble these things but i have problem. I have code for reading CSV file:

    int i = 0;
    foreach (string line in File.ReadAllLines("test.csv"))
    {
        string[] parts = line.Split(',');
        foreach (string part in parts)
        {
            Console.WriteLine("{0}",part);

        }

    }

But it gives one under the other output. Example:

1:ID

1:Employee

2:1

2:Thomas

And i want this table

ID Employee

1 Thomas

My code for generating table : (This generate 20x20 matrix)

 for (int i = 1; i < 20; i++)
 {
     TableRow tRow = new TableRow();
     Table1.Rows.Add(tRow);
     for (int j = 1; j < 20; j++)
     {
         TableCell tCell = new TableCell();
         tRow.Cells.Add(tCell);
         tCell.Text = i + ":" + j;
     }
 }

Thanks

Tân
  • 1
  • 15
  • 56
  • 102
Tamas B.
  • 181
  • 1
  • 1
  • 7
  • Don't parse CSVs yourself. You'll get it wrong. Use a library such as [CsvHelper](https://joshclose.github.io/CsvHelper/). – mason Feb 28 '17 at 18:35

0 Answers0