Results 1 to 4 of 4

Thread: how to skip to read particular line in a file

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to skip to read particular line in a file

    am having text file inside the file am having multiple lines of text
    Example
    6000
    aaa.jpg
    bbn.jpg
    ccc.jpg
    here i want to read each line in a file i want to skip the first line (6000).how its possible in QTextstream or any other method to skip the particular line ??please give me suggestion
    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to skip to read particular line in a file

    Simple:

    1) Read line
    2) do nothing with it

    Cheers,
    _

  3. #3
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: how to skip to read particular line in a file

    An alternative is to use the seek function.
    QTextStream::seek

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to skip to read particular line in a file

    Quote Originally Posted by Kryzon View Post
    An alternative is to use the seek function.
    QTextStream::seek
    Yes and no.
    seek() lets you skip over data, but it requires a position. You would need to know the position of the next line's end to seek to it.
    Which, unless there is a fixed line length, means reading until you hit the newline marker.

    Cheers,
    _

Similar Threads

  1. Skip NaN values in qwtplot
    By ivareske in forum Qwt
    Replies: 0
    Last Post: 12th October 2011, 14:01
  2. Read gzip file line-by-line
    By The_Fallen in forum Qt Programming
    Replies: 4
    Last Post: 6th September 2011, 13:41
  3. Replies: 1
    Last Post: 3rd February 2010, 07:44
  4. Qt Prog skip the file reading block
    By dgg32 in forum Qt Programming
    Replies: 10
    Last Post: 10th December 2008, 18:12
  5. skip function parameter
    By mattia in forum General Programming
    Replies: 4
    Last Post: 22nd November 2007, 15:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.