Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parsing CSV File

Parsing CSV File

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 685 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DSpiderD Offline
    DSpiderD Offline
    DSpider
    wrote on last edited by
    #1

    Hello,

    I am looking for a way to parse CSV file without having to reinvent the wheel. I found the libqxt library, but it seems that is not maintained anymore and developers even recommend not using it due to the changes in recent Qt versions.

    Is there any way to do it ?

    Best

    R 1 Reply Last reply
    0
  • mrjjM Offline
    mrjjM Offline
    mrjj Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    For simple CSV, Qt QString's split function makes it very easy.
    https://doc.qt.io/qt-5/qstring.html#split

    There is
    https://github.com/iamantony/qtcsv

    1 Reply Last reply
    4
  • R Offline
    R Offline
    Robert Hairgrove
    replied to DSpider on last edited by
    #3

    @DSpider And if the CSV text is more complex, for example containing binary data or embedded line feeds, there is this very nice little library which can do it: https://github.com/rgamble/libcsv

    However, it is written in C (not C++) and, although the field separator and the quote character can be freely chosen, requires that they are 8-bit characters. Usually, it is enough to ensure that the input is in UTF-8 encoding or some other 8-bit character set.

    The data is read sequentially from beginning to end, byte by byte. To use it, you need to write two callback functions which are called whenever a field is detected, and at the end of a line. I like it because I can validate the input data field-by-field.

    1 Reply Last reply
    3

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved