C# を使用して、csv ファイルを読み取り可能な形式に変換する小さなアプリを開発しています。
以下はCSVファイルのサンプルです
"Symbol","Date","Expiry","Strike Price","Open","High","Low","Close","LTP"
"5000","6000","4500","45855" ............
このような300行以上。
public List<string[]> parseCSV(string path)
{
List<string[]> parsedData = new List<string[]>();
try
{
using (StreamReader readFile = new StreamReader(path))
{
string line;
string[] row;
while ((line = readFile.ReadLine()) != null)
{
row = line.Split(','); // <<< this ',' is not working
parsedData.Add(row);
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
return parsedData;
}
データによると、LTP で新しい行を取得する必要がありますが、それは行われておらず、単一の行として結果が得られていません。リスト、つまりparseDataを追加すると、単一の行として表示されます。