Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Split CSV

Split CSV

Scheduled Pinned Locked Moved C#
questiondatabasemysqlhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Burim Rama
    wrote on last edited by
    #1

    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();

    M 1 Reply Last reply
    0
    • B Burim Rama

      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();

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • M musefan

        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

        B Offline
        B Offline
        Burim Rama
        wrote on last edited by
        #3

        you are the man ;-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups