Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where to store data?
#1
I am writing a program that will need to access a list of 100+ names that will be frequently edited. I am wondering what the best option is for storing this data. I am leaning toward a spread sheet type file like .xls and .csv, or just putting it all in a dict or list in memory. I just want some opinions on what would be a good approach.
Reply
#2
What are your requirements? Just storing and editing 100+ names? You won't need disk for that, unless you need the data to persist in the event of the machine being turned off.

If that is the case, and the dictionary is simple, you can dump it to JSON and read it back without any special processing. csv/tsv might work as well, but you can probably find a JSON representation that would be a better fit for the data.
Reply
#3
Depends on the project/use, but generally I would go for sqlite, next option - json/csv. Using json or csv file would require writing all the info into the file every time you change something, while using sqlite allows to update the info in db only for whatever changes have been made. If going for json/csv - I would read everything in the memory on script start and use the names from there, only saving back to file when there are changes.
Reply
#4
You can just pickle a list of objects like simple names. Pickle is a standard Python module which dumps Python objects on the disk as a binary file. It's easier for Python. But in that way other programs won't use the data. JSON is a good choice if that is required
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
(Feb-13-2017, 06:32 AM)mcmxl22 Wrote: I am writing a program that will need to access a list of 100+ names that will be frequently edited. I am wondering what the best option is for storing this data. I am leaning toward a spread sheet type file like .xls and .csv, or just putting it all in a dict or list in memory. I just want some opinions on what would be a good approach.

100+ names (but less than 1000): just use a flat file, especially if humans will edit it.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Store variable data and display sum after 60 seconds the_dude 11 3,460 Dec-16-2021, 07:07 PM
Last Post: deanhystad
  Regex text file to store data in list TheSithSiggi 1 1,534 Dec-03-2020, 04:46 PM
Last Post: bowlofred
  How do I store the data in another txt file blacklight 1 1,941 Jun-26-2020, 11:09 AM
Last Post: Larz60+
  Read csv file, parse data, and store in a dictionary markellefultz20 4 4,587 Nov-26-2019, 03:33 PM
Last Post: DeaD_EyE
  Reading blob data from database by python and store it in .zip format Adityasi 2 6,619 Nov-18-2019, 05:22 PM
Last Post: ibreeden
  a contact book - a class made to store data apollo 2 1,954 Jun-12-2019, 04:33 PM
Last Post: apollo
  Receive Serial Data and store in different Variables in Python jenkins43 5 5,618 Dec-28-2018, 01:33 PM
Last Post: snippsat
  how to parse multipart/form-data for xls or jpeg stream into python code and store v71017 0 3,316 Mar-20-2018, 01:09 PM
Last Post: v71017
  How can i store a refreshing data Rius2 2 2,675 Dec-01-2017, 08:12 PM
Last Post: Rius2

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020