public static ReadCSV ( string filePath ) : ].string[ | ||
filePath | string | |
리턴 | ].string[ |
public static string [,] ReadCSV (string filePath) {
string csvAsString = FileUtil.FileText(filePath);
string[] byLine = csvAsString.Split('\n');
int columns = GetMaxRowLength(byLine);
int rows = byLine.Length;
string[,] byCell = new string[columns, rows];
for (int x = 0; x < columns; x++) {
for (int y = 0; y < rows; y++) {
byCell[x, y] = byLine[y].Split(',')[x];
}
}
return byCell;
}
/// <summary> /// CSV 表映射到对象 /// </summary> private Dictionary <int, T> ReadCSVTable <T>(string csvName) { Dictionary <int, T> csvTable = new Dictionary <int, T>(); CSVUtil.ReadCSV(csvName, csvTable); return(csvTable); }