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

  • 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 or in my opinion better way a c++ class where you ust use the default "QFile": to read the file and then process it in c++ and send the "array" back to QML.

  • Hey please check now 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 = [
    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

Log in to reply