Read text file in array
-
hey i ahve a text file in which there are 3 coulmns ...i want to make array for each coulmn individually .
how i can do this.i am adding my text file here https://drive.google.com/file/d/0BwR7_R9HuUvpa2R0WmlGZnVPbzg/edit?usp=sharing -
Hi, first the file is not publicly available I think.
If you want to read a file in QML you can either use a XMLHttpRequest (tutorial http://qmlbook.org/ch11/index.html#local-files) or in my opinion better way a c++ class where you ust use the default "QFile":http://qt-project.org/doc/qt-5/QFile.html to read the file and then process it in c++ and send the "array" back to QML. -
Hey please check now ...you can access now this file.
I am not using QML ...i am using QFile through this we can read all data of files.but there are three coulmn and i want to make array for each coulm individually.please suggest me some way how i can do this. -
Hi, can you maybe give an example or function prototype how you would like to use it? It should be fairly easy to read that file in and split the columns.
what i mean do you want a separate array for each column or a multidimensional array e.g.
@
// separate array for each column
c1 = [1,2,3,...]
c2 = [4,5,6,...]
c3 = [7,8,9,...]
// or multidimensional array
a = [
[1,2,3,...]
[4,5,6,...]
[7,8,9,...]
]
@
or something else?Also you know there is no way you can return multiple values with one return value, you could use callback function or "wrapper" like a std::tuple but then again you could just use a multidimensional array in the first place :D