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. Reading text file to specific sign in each line

Reading text file to specific sign in each line

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 719 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.
  • E Offline
    E Offline
    emdoa
    wrote on last edited by
    #1

    Hi,

    I need to read some words from a text file looks like below:
    @
    01 00000101 # reset
    01 0f020001 # ADC power down
    01 31000101
    01 25004001
    01 0f000001 # single channel
    ...
    @
    As you can see there is specific comment sign in most of lines, so I need to stop saving words at this moment and move to next line, is there any implemented function to do this ? Next I can store all words in QbyteArray or something similar as usual.
    Can anyone help me?

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

      Hi and welcome to devnet,

      You can read the file line by line and check for the presence of the comment char then do what you want.

      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
      1
      • C Offline
        C Offline
        Charlie_Hdz
        wrote on last edited by
        #3

        @emdoa

        You can use a variety of Objects (QTextStream for example) even from standard (StringStream). Please look deeply at this types and some simple statements will work fine for you.

        It would be so easy as a loop with a inner if (or flag).

        Thank you.

        Kind Regards,
        Enrique Hernandez
        gearstech.com.mx
        chernandez@gearstech.com.mx

        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