Actually, I have a .csv file which has (userID,movieID,rating) seprated by commas. now, I have to read it and also make another .csv in the output. Can anyone tell me how to read a .csv file and take that data in integer (as userid , rating etc are integers). from google, i found that .csv is a normal plain text file that has data seprated by columns. Thanks in advance. :)
P.S help in C or either C++ will be helful. no problem with C++ as i have a good hand in C++ also. thanks.
nitin1 15 Master Poster
Recommended Answers
Jump to PostPost a few lines of the csv (comma separated values):
http://en.wikipedia.org/wiki/Comma-separated_valuesthat you are having trouble with the input, and your code.
It's best to get into the specifics, and see the actual …
Jump to PostIt's fairly easy to accomplish in either language. In C, call fgets() to read each line, separate it into tokens with strtok(), then convert each string token into integers using atol() (or one of several other conversion functions).
In C++ it's a little simpler, call getline() with a line terminator …
Jump to PostIn general you are right, but I don't think his csv file contains any text -- all numeric. So complicating the code by parsing for quoted material is unnecessary.
All 11 Replies
Adak 419 Nearly a Posting Virtuoso
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
nitin1 15 Master Poster
nitin1 15 Master Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
nitin1 15 Master Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
nitin1 15 Master Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.