Thread: creating files

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0

    creating files


    i want to create a file type which is unique to my program, abd they will end in .qea

    each one will store text and images, but i have no idea how i can go about doing this - is there a specific method to creating files unique to a program?

    Thanks.
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    What a file contains is totally up to you. To associate the file with your executable you will need to access the registry to add the right keys and values.

    I've not used them but there are methods in the WIN32 extension package to allow registry editing but I would not use them until you have thoroughly investigated what keys are needed and how they should be manipulated.

    grim
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0
    What a file contains is totally up to you.
    i know, but i was kindof wondering how i would go about making my unique file frmat containg text and images. my idea was maybe to have all the text at the top, and then the image data after that, each image being seperted by a unique character, so that code could seperate the images after the file has been opened?
  6. #4
  7. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Originally Posted by yabadabastum
    i know, but i was kindof wondering how i would go about making my unique file frmat containg text and images. my idea was maybe to have all the text at the top, and then the image data after that, each image being seperted by a unique character, so that code could seperate the images after the file has been opened?
    Well I over design these things on the assumption that if it can happen it will. The simplest way for me would be to add the length of the text at the beginning - then its easy to read off any number of characters.

    But how about using pickle to save and load your data.
    That way you can put all you files data into a dictionary then write it to a file. Then you can unpickle it and recover the dictionary. It does all that mangling and measuring for you

    grim
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0
    looks like i have a few choices

    I am not sure whether to store every record as a file - this would give the users an easy way of moving info between computers - or maybe i should use one computer as a database / server, so they can all connect to it.

    It's for an estate agent
  10. #6
  11. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Perhaps you should consider MySQL and pythons database API as the way to go.

    If you want a light weight solution using pickle you could try my persistent datatypes module ptypes:
    http://www.peck.org.uk/p/python/

    grimey
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0
    hmm i am not too sure about using an actual database server - just a non-server database and something like PYRO. maybe sqllite. i think even mysql is abit too bulky for what i am after.i will check out that link though!

    I think maybe i will use mysql for development just so i can use phpmyadmin as a development tool and then switch to something with a smaller footprint when i have all my SQL code in the bag!
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Regensburg, Germany
    Posts
    147
    Rep Power
    16
    Another simple method to store "mixed" data (e.g. graphic, text, office documents or whatever) within one file ist to create a zip archive using the zipfile library module. You don't have to bother with text length, file offset or special separation characters, just acces the parts within a zip archive by a unique name. It's no problem to give the zip archive another extension than .zip, and it has the big advantage that you can view the archive content using a zip program like winzip or gzip. I've used this method several times and it works great.
    If speed is important and file size doesn't matter, use the same method but with zero compression.
  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I wrote an article for Devshed on using Python with zip files a while back that you might he interested in if you deside to go down this rout:

    http://www.devshed.com/c/a/Python/Python-UnZipped/

    Hope this helps, enjoy!

    Mark .
    programming language development: www.netytan.com Hula

  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0
    cheers sb that might be what i am after. I am now debating on whether to do what you suggested or using a database. It comes down to what is gonna be best for the end users i guess - the trouble is - i don't really know what would be best. With files - they could create / edit / ship around and the files would have their own extension / icon, which would be professional and also be great over multiple branches - the files could be emailed about.

    but - there is risk that not everyone gets the data that way - if a file is created on 1 computer, it will need to be present on all others computers running the program in the office because the data has to be viewed by everybody working. In that respect the database idea seems great and having files seems pointless!

    If i had both - this could lead to confusion because a users files would be updated whenever another user on a different computer updates them!
  20. #11
  21. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Its probably best to think as a zip file as being a way of grouping files together -- similar to a bundle on the Mac.

    There are many advantages to this: as sb said, any zip program will be able to view and or extract the individual files as needed, this will increase compatability with computers/users/clients that don't have your program installed.

    Also as mentioned by sb this will still allow you to have a custom file extension (& icon) associated with your program like you wanted .

    Now some added by me: it's a lot easier to email someone one file than it is to email them 10 individual files , and you'll be able to take advantage of smaller file sizes. The list goes on...

    Ultimately its up to you in which direction you choose to go in but I would be inclined to go with the archive idea.

    Good luck ,

    Mark.
    programming language development: www.netytan.com Hula

  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0
    netytan - you may have been mistaken - i meant one (zip) file per property - so say there are 1000 properties there will be 1000 zip files. Actually now i have said that it looks abit rediculous
  24. #13
  25. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Mmmmm. What I thought you wanted to do was to have a file that stored a bunch of other files: a few images and some .html files for example then have your program load the files and and so whatever with them; not knowing what it is your program will be doing , but if this is the case then you only need one zip file to store all your other resources.

    Am I getting warm here?

    Mark.
    Last edited by netytan; December 20th, 2004 at 11:03 AM.
    programming language development: www.netytan.com Hula

  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    346
    Rep Power
    0
    ok this is what i am doing - making an admin program to be used in estate agent offices. It's core functionality will be to add / delete properties. Each property will have many details associated with it, and also a few photos. the program will run on each computer in the office - my orignal idea being one computer running as the master - and have a database of image locations and details - and other computers copying to / getting data from this computer.

    whatever the solution - each computer in the office will need a full and fully updated set of data to work with.

    Any ideas
  28. #15
  29. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Now I get it, just with your saying properties I assumed you ment something like a property list [properties for the program]. My bad .

    Anyway I'm with Grim and the database then. If you're going to have multiple computer gathering data from a central computer on the network its probably better to use a database like MySQL.

    This way you don't have to worry about a property being removed on one computer and another computer still thinking it's available or whatever . In-fact this sounds a lot like a web application.

    Mark.
    programming language development: www.netytan.com Hula

Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo