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. Writting blocks of data in TextFile
Forum Update on Monday, May 27th 2025

Writting blocks of data in TextFile

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiletext file
11 Posts 4 Posters 1.2k 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.
  • B Offline
    B Offline
    Babs
    wrote on last edited by Babs
    #1

    Hello,
    What is the easiest way to write repetitive blocks of data into a Text file.
    For example a structure like this:

    EVENEMENT
    INSTANT = 32
    ENTREES
    	E19 = FAUX
    	E20 = FAUX
    FIN
    
    EVENEMENT
    INSTANT = 34
    ENTREES
        E21 = FAUX
        E22 = FAUX
    FIN
    
    EVENEMENT
    INSTANT = 36
    ENTREES
        E21 = VRAI
    	E22	= FAUX
    FIN
    
    EVENEMENT
    INSTANT = 38
    ENTREES
        E23 = FAUX
        E24 = FAUX
    FIN
    
    EVENEMENT
    INSTANT = 40
    ENTREES
        E23 = FAUX
        E24 = VRAI
    FIN
    

    This data is read from an excel file.

    1 Reply Last reply
    -1
    • gde23G Offline
      gde23G Offline
      gde23
      wrote on last edited by
      #2

      Just write it to the file. Or what exactly is the question?

      B 1 Reply Last reply
      3
      • gde23G gde23

        Just write it to the file. Or what exactly is the question?

        B Offline
        B Offline
        Babs
        wrote on last edited by
        #3

        @gde23 I want add each block automatically not write manually every single line.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Where are the data coming from ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Where are the data coming from ?

            B Offline
            B Offline
            Babs
            wrote on last edited by
            #5

            @SGaist the data is coming from a complex excel file

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              So you have to read them from that Excel file, do some processing and write the result to a text file ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              B 1 Reply Last reply
              0
              • SGaistS SGaist

                So you have to read them from that Excel file, do some processing and write the result to a text file ?

                B Offline
                B Offline
                Babs
                wrote on last edited by
                #7

                @SGaist exactly

                JonBJ 1 Reply Last reply
                0
                • B Babs

                  @SGaist exactly

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #8

                  @Babs
                  So at some level do you want to (use QFile & QTextStream to) loop reading the lines from the file, do whatever modification appropriate in memory, and write the resultant line back out to a new file? Or, you can read all the lines into a QList in memory, make all the changes, and write the whole new file back.

                  B 2 Replies Last reply
                  0
                  • JonBJ JonB

                    @Babs
                    So at some level do you want to (use QFile & QTextStream to) loop reading the lines from the file, do whatever modification appropriate in memory, and write the resultant line back out to a new file? Or, you can read all the lines into a QList in memory, make all the changes, and write the whole new file back.

                    B Offline
                    B Offline
                    Babs
                    wrote on last edited by
                    #9

                    @JonB i thougth about using QSettings but my files extensions are not .ini.

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Babs
                      So at some level do you want to (use QFile & QTextStream to) loop reading the lines from the file, do whatever modification appropriate in memory, and write the resultant line back out to a new file? Or, you can read all the lines into a QList in memory, make all the changes, and write the whole new file back.

                      B Offline
                      B Offline
                      Babs
                      wrote on last edited by
                      #10

                      @JonB for now i created a QLIst and read the data with QTextStream

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        What do you put in your QList ?

                        Can you explain what is the exact issue you are having with writing the content you are reading from the Excel file to another text file ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        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