Read CSV and parse



  • Hi all.
    I am new with Qt.
    I need to create a code that will read a selected csv file in any folder and extract the information.
    The data in the csv file is numbers.
    The format is:
    Column, point, latitude (DDMMSS.ss hemisphere), longitude (DDMMSS.ss hemisphere), X (UTM), Y (UTM), data 1, data2).
    I used QString and Openfiledialog to indicate the file and read.
    How do I read the information line by line?



  • @Renato_Brasil
    You may have a look at the QFile documentation. There is an example how to read a file line by line


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    This wiki article might also be of interest.



  • @the_ Thanks!



  • @SGaist Thanks!


  • Qt Champions 2016

    @Renato_Brasil
    and for splitting, please see
    http://doc.qt.io/qt-5/qstring.html#split
    it will u give u a list of all the keys pr line

    ps. if huge file please read about the
    QVector<QStringRef> QString::splitRef

    its has better performance than the other but if small file and Desktop app, it wont matter much.


Log in to reply