Read and Search a CSV file

May 30, 2012 at 1:25am
hi. i know my question is a basic one, but i am a noob when it comes to c++. now, how do i search a csv file?. e.g. i will enter an employee id and it will return the name and address of that employee id. thank you
May 30, 2012 at 5:42am
Removed
Last edited on May 30, 2012 at 6:30pm
May 30, 2012 at 6:44am
> i will enter an employee id and it will return the name and address of that employee id.

If you are going to do this repeatedly, read the file once and populate an associative array with the employee id as the key.
http://www.cplusplus.com/reference/stl/map/

Parsing a csv file correctly could get slightly tricky with quoted strings and the like - perhaps you should let boost::escaped_list_separator<> do the parsing for you.
http://www.boost.org/doc/libs/1_49_0/libs/tokenizer/escaped_list_separator.htm
Topic archived. No new replies allowed.