[Tutor] Help with storing a variable
ThreeBlindQuarks
threesomequarks at proton.me
Tue Oct 31 21:48:10 EDT 2023
NN,
Your question is wide open with many possible solutions.
You say you are storing (presumably reading in if a specific EXCEL file exists, and the updating or rewriting it) so clearly the obvious place is the same file. This would allow portability.
Allen has already suggested a database for all the data as a better alternative but that could require the machine you store it on be known and have the right software.
Do note that handling EXCEL files requires one of many modules that would need to be available and reading just a part of a sheet for data and another for stored variables has some drawbacks. You may want to consider having two or more tabs with one being the current data and another one or more containing other info or even the backup of the data before you updated it.
There are many in-between solutions to consider which can include saving info in multiple text files with perhaps one in CSV format, or even hiding the saved data in a comment in such a file to keep them together. Other options let you save data in text or binary files in ways that can easily be retrieved. Some are much faster to work with than EXCEL or easier to update perhaps in place and to work with any other programs that may need to interoperate with your data.
You may know about your needs and choose what works. My first choice would not be EXCEL unless someone needs to be able to access it certain ways or update it.
Sent with Proton Mail secure email.
------- Original Message -------
On Tuesday, October 31st, 2023 at 7:43 AM, nadeem nan via Tutor <tutor at python.org> wrote:
> Hi Alan,
> I hope you are doing well. I am a beginner at Python and as a practice trying to code a rental property management application using tkinter/ttkbootstrap as GUI and MS Excel to store the data.
> In the application, the end user (here the property agent) can add tenants and their details, properties, rent etc. What I am trying to do is whenever the user adds a new tenant via the user interface, it will generate a tenant-code like MR0001 for a male tenant or MS0001 for a female tenant and the numbers would increment as more tenants are added.
> I was wondering how would I go about storing this tenant-code so when the user returns to the application to add more tenants the tenant-code is incremented from where it was left.
> My idea is to store a variable for tenant-code some where in the excel sheet where the tenants data is being saved. This variable can be then accessed when the application is used and incremented accordingly. Do you think this idea would work or if you have a better and efficient way, please let me know.
> I haven't started coding yet but just gathering ideas on paper. Any help will be much appreciated.
> I look forward to hearing from you soon.
>
> Regards,
> Nadeem Nan
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list