Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. CSV to JSON Method with QML
Qt 6.11 is out! See what's new in the release blog

CSV to JSON Method with QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 553 Views 1 Watching
  • 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.
  • T Offline
    T Offline
    tacdin
    wrote on last edited by
    #1

    Hi, I'm selecting a local document with a FileDialog. After selecting the document I want to see the contents of the document. Document format csv. I'm trying to convert from CSV to JSON, but I'm still stuck reading the document content. Even if I read the document content, I cannot view it. Unfortunately, the links I found while doing research are outdated. Can anyone help me on how to read the document and convert it from CSV to JSON?

    Attached 1st link offers a solution with C++. I am looking for a JS based solution.
    In the second link, TableSerializer, selectionModel, TableModel (displayRoleProvider and editRoleProvider dont work ) give "unknown component" warning.

    1. LINK
    2. LINK

    TableSerializer {
            id: tableSerializer
        }
    
    Component {
            id: tableModelFactory
            TableModel {
                id: tm
                displayRoleProvider: function(row, column, v) {
                    var vdata = JSON.parse(v)
                    var ret = v
                    var val = null
                    if (val = vdata["formula"])
                        ret = evaluateFormula(val, row)
                    else if (val = vdata["date"])
                        ret = val
                    print("displayRoleProvider", row, column, v, ret)
                    return ret
                }
                editRoleProvider: function(row, column, v) {
                    var vdata = JSON.parse(v)
                    var ret = v
                    var val = null
                    if (val = vdata["formula"])
                        ret = val
                    else if (val = vdata["date"])
                        ret = val
                    print("editRoleProvider", row, column, v, ret)
                    return ret
                }
            }
        }
    
    1 Reply Last reply
    0

    • Login

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