1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Read and Search csv file using C

Discussion in 'C' started by electroon, May 25, 2013.

  1. electroon

    electroon New Member

    Joined:
    May 25, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    HI All,

    I was hoping someone could assist with the following coding;

    I am trying to search a very large csv file (approx 200,000 lines) for a array of strings and get the output as the line where there text is found.
    E.g. CSV file:
    123,A,B,C
    456,D,E,F
    123,G,H,I
    Now if I search for 123
    my output array should give me
    A,C
    G,I

    Could anyone please help with the coding for this, I need a pure C code for this? I am concerned with the very large csv I am using which will prob slow everything down.

    Would appreciate any help on this,

    Kind Regards,
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    How far have you got and where are you stuck?
    Do you understand the project requirements?
    How large in bytes is your CSV file?

    Are you really searching for an array of strings, or just the first column value?

    I wouldn't worry too much about the size. Computers are very good at searching large files very quickly. Just do a line by line search and see how long it takes first time through; if this is a repeated task that needs to complete in a specific amount of time, and that amount of time is less than the time available, then you may need to think about how to optimise the search, but not before. Premature optimisation is a root of all kinds of evil.
     

Share This Page