hey,
i have to do the following in c:
i want to read data from a csv file.
i need to read the first, second and fifth column of the file.
i am using fread but i cant get it to read the desired data.
What pukur123 is suggesting amounts to using linux commands to split the columns into separate files. But that won't help you if you want to read the csv data into variables of your C program, you'll need to use C commands and there is one ideally suited for what you want to do (that will work in linux and windows):
fscanf
Use fgets() to read a line at a time and then use strchr() to find a comma (also look at strtok() which you may or may not find easier to use).
fscanf() is even simpler than fgets() when you know in advance what format to expect; you won't need to search for commas and date slashes, etc.
[EDIT:] Whoops, I didn't notice this thread was started in 2006...[/EDIT]