Split CSV
-
Hey everbody I have a big problem to upload one csv fil to mysql database. i have a big csv file with many records and column Eks.: ArticleNo ManArticleNo DescShort DescLong Manufacturer Price Stock 642 0993A001 BJ-642/black 790sh f BJ300 330 Canon blækpatron, sort (BJI-642BK) Canon 97,11 0 665 1009A001 BJC-643/black f BJC-800 820 880 Canon blækpatron, sort (BJI-643BK) Canon 157,43 0 673 1012A001 BJC-643/yellow f BJC-800 820 880 Canon blækpatron, gul (BJI-643Y) Canon 203,42 0 3131 51604A HP Ink Cart/Black f ThJet QJet+ f plain HP blækpatron, sort (CJ-3A) Hewlett Packard 57,91 115 3135 51605R HP Ink cart/red f Think- Quietjet HP blækpatron til ThinkJet/QuietJet, magenta Hewlett Packard 63,63 0 i load the file like this StreamReader input = new StreamReader(@"c:\test.csv"); string inputLine = ""; while ((inputLine = input.ReadLine()) != null) { but now i need just to take ManArticleNo and Price from the inputLine my input line has all the row, how can i split or somthing to take just that column i need ? string tr = inputLine.?(?); } input.Close();
-
Hey everbody I have a big problem to upload one csv fil to mysql database. i have a big csv file with many records and column Eks.: ArticleNo ManArticleNo DescShort DescLong Manufacturer Price Stock 642 0993A001 BJ-642/black 790sh f BJ300 330 Canon blækpatron, sort (BJI-642BK) Canon 97,11 0 665 1009A001 BJC-643/black f BJC-800 820 880 Canon blækpatron, sort (BJI-643BK) Canon 157,43 0 673 1012A001 BJC-643/yellow f BJC-800 820 880 Canon blækpatron, gul (BJI-643Y) Canon 203,42 0 3131 51604A HP Ink Cart/Black f ThJet QJet+ f plain HP blækpatron, sort (CJ-3A) Hewlett Packard 57,91 115 3135 51605R HP Ink cart/red f Think- Quietjet HP blækpatron til ThinkJet/QuietJet, magenta Hewlett Packard 63,63 0 i load the file like this StreamReader input = new StreamReader(@"c:\test.csv"); string inputLine = ""; while ((inputLine = input.ReadLine()) != null) { but now i need just to take ManArticleNo and Price from the inputLine my input line has all the row, how can i split or somthing to take just that column i need ? string tr = inputLine.?(?); } input.Close();
string[] columns = inputLine.Split(',');//',' for .csv, '\t' if tab delimeters etc.
then you just reference the index of the columns you want e.g.
string ManArticleNo = columns[0];//or whatever index
then you do the database update stuff
My opinion is... If someone has already posted an answer, dont post the SAME answer
-
string[] columns = inputLine.Split(',');//',' for .csv, '\t' if tab delimeters etc.
then you just reference the index of the columns you want e.g.
string ManArticleNo = columns[0];//or whatever index
then you do the database update stuff
My opinion is... If someone has already posted an answer, dont post the SAME answer
you are the man ;-)