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 Updated to NodeBB v4.3 + New Features

Writting blocks of data in TextFile

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiletext file
11 Posts 4 Posters 1.3k Views 2 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.
  • B Offline
    B Offline
    Babs
    wrote on 17 Aug 2020, 08:44 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
    • G Offline
      G Offline
      gde23
      wrote on 17 Aug 2020, 09:11 last edited by
      #2

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

      B 1 Reply Last reply 17 Aug 2020, 09:13
      3
      • G gde23
        17 Aug 2020, 09:11

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

        B Offline
        B Offline
        Babs
        wrote on 17 Aug 2020, 09:13 last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 17 Aug 2020, 18:38 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 18 Aug 2020, 07:14
          0
          • S SGaist
            17 Aug 2020, 18:38

            Hi,

            Where are the data coming from ?

            B Offline
            B Offline
            Babs
            wrote on 18 Aug 2020, 07:14 last edited by
            #5

            @SGaist the data is coming from a complex excel file

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 18 Aug 2020, 07:32 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 18 Aug 2020, 07:45
              0
              • S SGaist
                18 Aug 2020, 07:32

                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 18 Aug 2020, 07:45 last edited by
                #7

                @SGaist exactly

                J 1 Reply Last reply 18 Aug 2020, 08:11
                0
                • B Babs
                  18 Aug 2020, 07:45

                  @SGaist exactly

                  J Online
                  J Online
                  JonB
                  wrote on 18 Aug 2020, 08:11 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 18 Aug 2020, 09:09
                  0
                  • J JonB
                    18 Aug 2020, 08:11

                    @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 18 Aug 2020, 09:09 last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • J JonB
                      18 Aug 2020, 08:11

                      @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 18 Aug 2020, 09:10 last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 18 Aug 2020, 15:07 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

                        8/11

                        18 Aug 2020, 08:11

                        • Login

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