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 836 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.
  • D Offline
    D Offline
    DSpider
    wrote on 10 Jul 2020, 21:59 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 16 Jul 2020, 09:28
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 11 Jul 2020, 06:54 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
      • D DSpider
        10 Jul 2020, 21:59

        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 Offline
        R Offline
        Robert Hairgrove
        wrote on 16 Jul 2020, 09:28 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

        3/3

        16 Jul 2020, 09:28

        • Login

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