sorting csv file

2007-07-07
2013-04-25
  • Hi,

    I would like to sort big csv files according to some columns.
    For example, I have a file with the following format :
    firstname;lastname;address;phone
    Which I would like to sort the lines in the following order: lastname then firstname.

    Is the stxxl library an appropriate tool for doing that?
    If so, how should I proceed ?

    I am not really familiar with I/Os in C++.
    I made the examples work but I do not really know how to adapt them for my problem.

    Could you help me, please ?
    Thank you.

     
    • Hi,

      csv files have fields with variable lengths. Unfortunately, stxxl can not deal with variable-length records. You can still sort string fields if there is a bound on their length, e.g. use "char str[MAX_LENGTH]" type to store them. See also
      <http://algo2.iti.uni-karlsruhe.de/dementiev/stxxl/report/node8.html>

      With best regards,
      Roman