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 / C++ / MFC
  4. Reading a .csv file

Reading a .csv file

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • M Offline
    M Offline
    mr2003
    wrote on last edited by
    #1

    Hi, How can I read raws and columns of a .csv file? I would like to move from one column to the next,, how can I do that ? Ehsan Behboudi

    D 1 Reply Last reply
    0
    • M mr2003

      Hi, How can I read raws and columns of a .csv file? I would like to move from one column to the next,, how can I do that ? Ehsan Behboudi

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      The raws (rows) of the file can easily be read with CStdioFile::ReadString(). The columns can be handled with AfxExtractSubstring(), or CString::Find(). There's more than one way to skin a cat, however.


      A rich person is not the one who has the most, but the one that needs the least.

      M 1 Reply Last reply
      0
      • D David Crow

        The raws (rows) of the file can easily be read with CStdioFile::ReadString(). The columns can be handled with AfxExtractSubstring(), or CString::Find(). There's more than one way to skin a cat, however.


        A rich person is not the one who has the most, but the one that needs the least.

        M Offline
        M Offline
        mr2003
        wrote on last edited by
        #3

        how do I use those commands in my code right now this is how I read my .csv file ifstream infile(file1); char temp[500]; infile>>temp; // so now i want to move to the next row or column, how do I do that with your syntax? Thanks Ehsan Behboudi

        D 1 Reply Last reply
        0
        • M mr2003

          how do I use those commands in my code right now this is how I read my .csv file ifstream infile(file1); char temp[500]; infile>>temp; // so now i want to move to the next row or column, how do I do that with your syntax? Thanks Ehsan Behboudi

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Very seldom do I use streams so this might not work, although it should get you close:

          istream in;
          while (in.eof() == 0)
          {
          is.getline(temp, sizeof(temp));
          // now do something with the line just read
          }


          A rich person is not the one who has the most, but the one that needs the least.

          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