dictionary to file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Enrique Palomo Jiménez

    #1

    dictionary to file

    Hi all,

    I'm writing an application who needs to handle a lot of information of several files.
    So, i think the better way is design a batch process to catch that information in a dictionary and write it in a file.
    So, after that when a user wants to retrieve something, only with an execfile i'll have all the information avaiable.

    Creating the file with pythonic syntax will be a hard job so,

    is there some module to do that?
    is there a better way?

    The information will be used no more than 3-4 days a month and install databases is not allowed.

    Thanks
  • Max M

    #2
    Re: dictionary to file

    Enrique Palomo Jiménez wrote:[color=blue]
    > Hi all,
    >
    > I'm writing an application who needs to handle a lot of information of several files.
    > So, i think the better way is design a batch process to catch that information in a dictionary and write it in a file.
    > So, after that when a user wants to retrieve something, only with an execfile i'll have all the information avaiable.
    >
    > Creating the file with pythonic syntax will be a hard job so,
    >
    > is there some module to do that?
    > is there a better way?[/color]


    You can easily pickle a dictionary and save that to a file.

    Source code: Lib/pickle.py The pickle module implements binary protocols for serializing and de-serializing a Python object structure. “Pickling” is the process whereby a Python object hierarchy is...


    --

    hilsen/regards Max M, Denmark


    IT's Mad Science

    Comment

    • Larry Bates

      #3
      Re: dictionary to file

      You don't define what you mean by "a lot". Python can read
      a tremendous amount of information from files in a very short
      amount of time so I wouldn't try to prematurely optimize this.
      Just read the information and see how long it takes. If it
      is really a long time, then look for alternatives. It will
      take some time to read the dictionary and to unpickle it.

      -Larry

      Enrique Palomo Jiménez wrote:[color=blue]
      > Hi all,
      >
      > I'm writing an application who needs to handle a lot of information of several files.
      > So, i think the better way is design a batch process to catch that information in a dictionary and write it in a file.
      > So, after that when a user wants to retrieve something, only with an execfile i'll have all the information avaiable.
      >
      > Creating the file with pythonic syntax will be a hard job so,
      >
      > is there some module to do that?
      > is there a better way?
      >
      > The information will be used no more than 3-4 days a month and install databases is not allowed.
      >
      > Thanks[/color]

      Comment

      • Larry Bates

        #4
        Re: dictionary to file

        You don't define what you mean by "a lot". Python can read
        a tremendous amount of information from files in a very short
        amount of time so I wouldn't try to prematurely optimize this.
        Just read the information and see how long it takes. If it
        is really a long time, then look for alternatives. It will
        take some time to read the dictionary and to unpickle it.

        -Larry

        Enrique Palomo Jiménez wrote:[color=blue]
        > Hi all,
        >
        > I'm writing an application who needs to handle a lot of information of several files.
        > So, i think the better way is design a batch process to catch that information in a dictionary and write it in a file.
        > So, after that when a user wants to retrieve something, only with an execfile i'll have all the information avaiable.
        >
        > Creating the file with pythonic syntax will be a hard job so,
        >
        > is there some module to do that?
        > is there a better way?
        >
        > The information will be used no more than 3-4 days a month and install databases is not allowed.
        >
        > Thanks[/color]

        Comment

        Working...