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. Empty rows get loaded while Parsing CSV

Empty rows get loaded while Parsing CSV

Scheduled Pinned Locked Moved C#
jsonhelp
5 Posts 3 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.
  • J Offline
    J Offline
    jebin k
    wrote on last edited by
    #1

    Hi, I parsed a CSV file and loaded in a dataset. All the columns got loaded in the dataset with extra empty cells. I need only the columns in the CSV file with values to be parsed and loaded in Dataset. Can any one help me out. I am using the following Code to parse string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Text;HDR=No;FMT=Delimited\\\""; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter("Select * from " + file, conn); da.Fill(ds, "TextFile");

    L K 2 Replies Last reply
    0
    • J jebin k

      Hi, I parsed a CSV file and loaded in a dataset. All the columns got loaded in the dataset with extra empty cells. I need only the columns in the CSV file with values to be parsed and loaded in Dataset. Can any one help me out. I am using the following Code to parse string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Text;HDR=No;FMT=Delimited\\\""; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter("Select * from " + file, conn); da.Fill(ds, "TextFile");

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Search CodeProject for an article that shows you how to do this.

      xacc.ide
      The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."

      J 1 Reply Last reply
      0
      • L leppie

        Search CodeProject for an article that shows you how to do this.

        xacc.ide
        The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."

        J Offline
        J Offline
        jebin k
        wrote on last edited by
        #3

        I searched CP but couldn't find anything. Can u plz get me any document regarding this.

        L 1 Reply Last reply
        0
        • J jebin k

          I searched CP but couldn't find anything. Can u plz get me any document regarding this.

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          IF you cant find , neither will I, try harder, I know it's there. Try Google!

          xacc.ide
          The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."

          1 Reply Last reply
          0
          • J jebin k

            Hi, I parsed a CSV file and loaded in a dataset. All the columns got loaded in the dataset with extra empty cells. I need only the columns in the CSV file with values to be parsed and loaded in Dataset. Can any one help me out. I am using the following Code to parse string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Text;HDR=No;FMT=Delimited\\\""; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter("Select * from " + file, conn); da.Fill(ds, "TextFile");

            K Offline
            K Offline
            kubben
            wrote on last edited by
            #5

            My guess would be that you opened the csv file in excel and then saved the file which added a bunch of extra empty cells. I would suggest adding some code to your csv parsing program that checks for extra empty cells and excludes them. Ben

            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