data from a csv file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhankrish
    New Member
    • Dec 2006
    • 16

    data from a csv file

    hello all,
    i've to write a C code to read data from an excel sheet (in CSV format) into a 2 dimensional array.
    the csv file has 100 columns and 5000 rows.
    but i am supposed to read in only 19 of these 100 columns.
    the 19 columns which i require are D, E, P, W, BC, BD, BO, CU, CV, etc.
    so you can see that the required columns do not occur together in the original excel file.
    can someone help me out?

    thanks.
    madhan
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    How far have you got?
    Can you open the file an read it line by line?
    Once you can you are left with the problem of parsing the lines into their cell valules.

    Comment

    • poojaarora
      New Member
      • Jan 2007
      • 1

      #3
      hi
      i m a user of turbo c.
      could u plz guide me how to read data from an excel sheet or any other text file
      how to read the file in array.

      Comment

      • Amit Sharma
        New Member
        • Jan 2007
        • 6

        #4
        Hi!
        Can u plz guide me how to read data from the excell sheet. please share the Code if u please allow.

        Comment

        • DeMan
          Top Contributor
          • Nov 2006
          • 1799

          #5
          I assume you know that a csv file stores cells of data as text (sometimes in quotation marks, depending on content) delimited by a comma?

          This means you can read in the file line, by line, splitting it each time you come accross a comma.

          Obviously, there is an order to the cells - D is 4th, E 5th, P 16th, W 22nd, BC 81st (I think) and the CU, CV are outside the 100 columns you mention.
          Either way, you set a loop to parse each line only storing the 4th, 5th, 16th etc value (and don't worry an empty cell IS still delimited by a comma).

          Comment

          Working...