CSV to JSON Method with QML
-
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.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 } } }