Python Forum
Saving the times a script is run to a file or ...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving the times a script is run to a file or ...
#2
(Oct-18-2022, 06:25 AM)3Pinter Wrote: My questions:
- which is the better format? I now would say json due the library style
- what if two users run (different) scripts at the same time. Could the file be 'open' thus creating an error? If so: can I catch that?
- is this saving to a network location a good approach?
  • "Which is the better format?" I would not choose json because a json file is supposed to contain one object and is not fit for appending. There are ways to fiddle about with the json principle but I would not do so. I would prefer a csv file.
  • Concurrency and file locking: that is an interesting question. A file object has a "closed" attribute which holds the value True or False, but I suspect this covers only the situation in one program. Not concurrent programs. You could do a test with one program opening a file for let's say one minute, and then a second program trying to open the same file. Does it produce an exception? Then you could use an try ... except construction to wait until the file is not locked anymore. If you are really concerned about this you should consider to use a database. A database will have mechanisms to handle concurrent updates. Even sqlite3 (included with Python) has these mechanisms.
  • I would certainly prefer a network location.
Reply


Messages In This Thread
RE: Saving the times a script is run to a file or ... - by ibreeden - Oct-18-2022, 10:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Music Python Script Repeating Number When Saving Facebook Photos ThuanyPK 2 241 May-13-2024, 10:59 PM
Last Post: ebn852_pan
  Code Assistance needed in saving the file MithunT 0 874 Oct-09-2022, 03:50 PM
Last Post: MithunT
  Saving the print result in a text file Calli 8 2,018 Sep-25-2022, 06:38 PM
Last Post: snippsat
  Trying to determine attachment file type before saving off.. cubangt 1 2,279 Feb-23-2022, 07:45 PM
Last Post: cubangt
  Showing and saving the output of a python file run through bash Rim 3 2,632 Oct-06-2021, 10:48 AM
Last Post: gerpark
  Problem in saving .xlsm (excel) file using pandas dataframe in python shantanu97 2 4,541 Aug-29-2021, 12:39 PM
Last Post: snippsat
  Need help with saving output into an excel file Beyondfacts 4 3,068 Mar-22-2021, 11:51 AM
Last Post: jefsummers
  Automating to run python script 100 times by changing parameters pmt 1 2,676 Dec-29-2020, 10:31 AM
Last Post: andydoc
  Saving text file with a click: valueerror i/o operation on closed file vizier87 5 4,577 Nov-16-2020, 07:56 AM
Last Post: Gribouillis
  Copy mp3 file multiple times and rename Mar10 4 3,890 Sep-23-2020, 01:09 AM
Last Post: Mar10

Forum Jump:

User Panel Messages

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