public static List <List <string> > Parse(string csvName) { Result parsed = Papa.parse(csvName); List <List <string> > rows = parsed.data; return(rows); }
public static List <Dictionary <string, System.Object> > getParsedCSV(string csv) { int csvHeaderLines = 1; TextAsset csvData = Resources.Load(csv) as TextAsset; Result parsed = Papa.parse(csvData.ToString()); List <List <string> > rows = parsed.data; List <string> csvHeader = new List <string>(); List <Dictionary <string, System.Object> > csvParsedData = new List <Dictionary <string, System.Object> >(); int csvLineIndex = 0; for (int listIndex = 0; listIndex < rows.Count; listIndex++) { csvParsedData.Add(new Dictionary <string, object>()); for (int subListIndex = 0; subListIndex < rows [listIndex].Count; subListIndex++) { if (listIndex < csvHeaderLines) { csvHeader.Add(rows [listIndex] [subListIndex]); } else { //NON HEADER BELOW csvParsedData [csvLineIndex].Add(csvHeader[subListIndex], rows[listIndex][subListIndex]); if (subListIndex.Equals(rows [listIndex].Count - 1)) { csvLineIndex += 1; } } } } return(csvParsedData); }
public static List <List <string> > ParseCSV(string csv) { TextAsset csvData = Resources.Load(csv) as TextAsset; Result parsed = Papa.parse(csvData.ToString()); List <List <string> > rows = parsed.data; return(rows); }
public void TestMethod1() { string filename = @"\\manaslu\WebApp\testcsv\sulabh\secondbackup\sambridhi_ProductExport06052017.csv";//@"D:\asinupdate.txt"; // Parse single file using (FileStream stream = File.OpenRead(filename)) { Papa.parse(stream, new Config() { complete = (parsed) => { List <List <string> > rows = parsed.data; var p = 0; }, error = (e) => { var errr = 0; } }); } }