-1

I'm making a program to allow users to input the details of a beer, and then rate it. There is then an option to search and rank beers depending on their rating. So when a new beer has been inputted, I need a way to save the name and it's score to be used in the search.

Lauren
  • 32
  • 5
  • 3
    Use a database (sqlite3, etc.), portable and easier way to save data in *my opinion* – vmemmap Sep 14 '20 at 18:23
  • 1
    Data can be saved in just about any format you can possibly imagine - plain text files, CSVs, Excel spreadsheets, databases, etc. – MattDMo Sep 14 '20 at 18:24
  • 1
    You can write the data in a text file, or, better, in a CSV or Excel file like here: https://stackoverflow.com/questions/13437727/writing-to-an-excel-spreadsheet – Chris Rahmé Sep 14 '20 at 18:24
  • 1
    @ChrisRahmé for searching, a DB is probably best. – MattDMo Sep 14 '20 at 18:25
  • 2
    Depending on the level of permanence you want, cuneiform tablets or engraved stone are the best options. – Mad Physicist Sep 14 '20 at 18:26
  • @MattDMo Of course. But this person looks new to programming and he won't have thousands of rows. Better not have to learn MySQL or whatever just for a small program like that. – Chris Rahmé Sep 14 '20 at 18:26
  • @ChrisRahmé. A CSV file has the additional advantage of being human-readable. Very important when starting out with programming. – Mad Physicist Sep 14 '20 at 18:27
  • @MadPhysicist Exactly. That's why I went for CSV and Excel. – Chris Rahmé Sep 14 '20 at 18:28
  • Just to reiterate: database. SQLite is a lite, easily portable variety. – S3DEV Sep 14 '20 at 18:28
  • 1
    @S3DEV. Keep in mind that OP is likely undergoing mild cognitive overload from just python. This may be either the best or the worst time to add in another language. Depends on how their mind works. – Mad Physicist Sep 14 '20 at 18:29
  • 1
    I'm really tempted to start working on a cuneiform tablet printer attached to an automated kiln because of this question. – Mad Physicist Sep 14 '20 at 18:30
  • @MadPhysicist - Absolutely agree; which is why I went for SQLite. Although, cuneiform tablets are a time tested solution! ;-) – S3DEV Sep 14 '20 at 18:31

2 Answers2

-1

depending on the complexity of data or what do you want to use. The simplest is the one from python Shelve which is practically a python dict backed up by a file There is a simple documentation in the link i provided.

StefanMZ
  • 453
  • 1
  • 4
  • 11
  • 1
    This should be a comment, and the question should be closed. – Mad Physicist Sep 14 '20 at 18:27
  • Why? It's a valid solution. – StefanMZ Sep 14 '20 at 18:30
  • 1
    @ChrisRahmé. Because the question is not specific and off topic on this site. – Mad Physicist Sep 14 '20 at 18:34
  • Please go through the site rules and show me which part this question fulfills: https://stackoverflow.com/help/how-to-ask – Mad Physicist Sep 14 '20 at 19:20
  • @user2099394. Just to be clear, I have no problem with beginner coders.We were all beginners at some point. There are some great tutorial resources out there for complete beginners. Stack Overflow is just not such a resource, and should not be treated as such. – Mad Physicist Sep 14 '20 at 19:23
  • I understand that those are guidelines , but there are some issues in the way you handled this: 1. you should have pointed to that link first (i don't know if i ever saw that link before) and a new user most cleary doesn't read it. 2. it doesn't say there that the question should be closed because of that (for me it looks like a guideline), but you know better 3. it shouldn't forbid users to respond to the question even if there are generic answers. 4. I don't say she did the right thing / right question, but you should chastise users for answering. – StefanMZ Sep 14 '20 at 19:36
  • That link is featured very prominently when you ask a question, especially as a beginner. It's really a problem that beginners tend to jump in and do whatever without reading the instructions directly in front of them. That behavior is not to be encouraged – Mad Physicist Sep 15 '20 at 03:03
  • @MadPhysicist sorry for causing a problem but I didn't know where to get an answer and have used Stack Overflow for other help. When making an account I was given no information that this is not for beginners. Hope that explains why I have asked. And thanks to everyone who has helped me! – Lauren Sep 17 '20 at 15:02
-1

You will need to store data in a DB like MySQL, Mongodb and Others. or You can choose to write to a file like csv, txt and many more.

Variable are stored in memory ( which resets on closing the program ).