nasıl oluyor da ‘oluyor’ ?

C# CSV Parser

6 Ocak, 2007 · Yorum Yapın

class CSVReader
{
public string[][] ParseCSV(string filename)
{
string[] linesOfFile;
string[][] cellsOfFile;
if (!File.Exists(filename))
throw new Exception(“File does not exist:”+filename);
linesOfFile = File.ReadAllLines(filename);
cellsOfFile = new string[linesOfFile.Length][];
for (int i = 0; i < linesOfFile.Length; i++)
cellsOfFile[i] = linesOfFile[i].Split(‘;’);
return cellsOfFile;
}
}

class TestCSVReader
{
public void Test()
{
string filename = “deneme.csv”;
string[][] cells = (new CSVReader()).ParseCSV(filename);
foreach (string[] line in cells)
foreach (string cell in line)
MessageBox.Show(cell);
}
}

Kategoriler: .NET · Güncel · Güzel şeyler · Programlama · İş güç

0 cevap so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Yorum Yapın