Read and Search csv file using C

electroon's Avatar, Join Date: May 2013
Newbie Member
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,
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.