I'm implementing a hashtable structure for a dictionary. Dictionary is in a text file. There are 2 words on each line. I'm generating the hashtable by using the first word as a key. I'm holding the hashtable on a list. I want to save the hashtable to a text file to use it every time. What kind of structure should I use? Is there a way to do this without reading the whole hashtable from text file?

  • 3
    The question doesn't make any sense. You're building a hashtable from a dictionary file - why do you need another file? – Ben Cottrell Apr 29 '12 at 15:11
  • to save the hashtable. – Rafaela Arcuri Apr 29 '12 at 15:16

You are looking for serialization.

In Python you could use pickle. In Java you can do it too. Almost every language has techniques for serialization.

If your hashtable becomes too big, you will have to use a relational database management sysyem, like MySQL, PostgreSQL, Oracle, SQL Server, etc.

  • 1
    Binary serialization can be a big pain, particularly if objects change over time. This leaves us with textual serialization, which should be ... just a CSV file with two columns : key and value :) – Job Apr 29 '12 at 19:24
  • That's what I thought too, but maybe for some reason she doesn't want to read or write the CSV again. – Виталий Олегович Apr 29 '12 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.