cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Read and Search a CSV file
Read and Search a CSV file
May 30, 2012 at 1:25am UTC
keitharanjuez
(1)
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 UTC
paulthepenguin
(79)
Removed
Last edited on
May 30, 2012 at 6:30pm UTC
May 30, 2012 at 6:44am UTC
JLBorges
(13770)
> 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.