ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
So, show us what you've written so far, and perhaps someone can offer some suggestions to help fix it. For parsing CSV data, you are going to need to make heavy use of string processing functions. strtok() is one that is probably useful, although it can be tripped up by commas embedded in quoted fields. It is almost impossible to suggest a general solution, unless someone knows of a canned library or source package for parsing such files, and it seems likely that such a package exists. I assume that you have a good reason for choosing a C implementation, rather than something like Perl, which makes such tasks almost trivial.
I don't see how paulsm4's code works for CSV files, either. It would seem to work fine for whitespace separated values. His point that C is the wrong tool for the job should be well taken however. My solution would probably involve something like Perl and the Text::CSV::Simple module. Since you haven't shown any actual data, nor have you given any indication how you wish to process the data, it is impossible to provide anything like a working example.