Results 1 to 9 of 9

Thread: How to use QList to add many QFiles.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use QList to add many QFiles.

    Thank you very much.How to design my program?Could you give me some advice?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to use QList to add many QFiles.

    Quote Originally Posted by weixj2003ld View Post
    How to design my program?Could you give me some advice?
    Only you know your requirements. Consider these things:
    • How many is "many files"? 5 is easy, 5000 would need a different approach.
    • What is being written? Text or binary blobs require different approaches.
    • How is it being written and how often? In response to an external event, or under your control. Every 50 milliseconds or every day. Different approaches needed.
    • The same thing to every file or different things? All the same... write one and duplicate it later
    • How close to real-time does it need to be? If you can accept a few seconds lag then other options are available.
    • Target files local or over a network? One performs better than the other.

  3. #3
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use QList to add many QFiles.

    Thank you for your answer very much.My requirement is :
    First I read about 10-15 column dignal datum (about 50000 rows) from one text file,and then write them into 10-15 (the same as column number) binary files differently.All the operations are in a local computer.
    Last edited by weixj2003ld; 16th July 2020 at 12:09.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to use QList to add many QFiles.

    First step : read all data to memory creating one list/vector for one column.
    Second step : write data to out files one after the other. In this case, you need a list of file names and you only have one file open at a time.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use QList to add many QFiles.

    First step : read all data to memory creating one list/vector for one column.
    Second step : write data to out files one after the other. In this case, you need a list of file names and you only have one file open at a time.
    This will work as long as the file can fit into memory, and a 15 x 50000 entry table is probably OK. If the files get to be too big to fit into memory, then there are at least two more options:

    1 - Open the file using memory mapping and let the OS take care managing the memory. If the data is stored in the file in row x column order, then you might want to take your original approach of keeping 10 - 15 files open so the memory mapping will be efficient.

    2 - Don't load the file into memory, but read through it 10 - 15 times, once for each column.

    It really depends on how often you want to do this conversion. If it is something you do once for each batch of data, then it really doesn't matter if it takes 1 second or 10 seconds. If it is something you will do a lot (eg. you are trying to keep up with real-time data acquisition), then you want it to be as fast as possible.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. #6
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use QList to add many QFiles.

    Thank you all,I will try it.

Similar Threads

  1. Replies: 4
    Last Post: 6th September 2019, 14:05
  2. Qlist<QLabel *> in Qlist<QAction*>
    By Naahmi in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2011, 08:53
  3. Cast QList<Foo*> to QList<const Foo*>
    By vfernandez in forum Qt Programming
    Replies: 0
    Last Post: 4th October 2010, 16:04
  4. Replies: 4
    Last Post: 20th August 2010, 13:54
  5. QList: Out of memory - without having defined QList
    By miroslav_karpis in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2009, 08:42

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
  •  
Qt is a trademark of The Qt Company.