Answer the question
In order to leave comments, you need to log in
How to make a python script accept a work schedule file?
I need a python script to schedule an action to turn on/off a device. There can be several devices themselves, each with its own schedule.
How convenient to organize this very schedule? It occurred to me to make the chart a file (one file for all devices). And this file will read the script and work on it. But here's how to do it? What to use? Is it possible in excel somehow?
Answer the question
In order to leave comments, you need to log in
A .xlsx (not .xls!) file can be read by python, even without third-party libraries - it's just a zip archive with a bunch of xml files inside.
But if there is no need to accept data from an untrained user, I would choose json . It is a popular and simple text format that supports hierarchical data structures (in python terms, lists and dictionaries).
Alternatively, you can try yaml , its syntax is not so noisy. But out of the box, python does not support it, you need to install the appropriate third-party pip package.
In terms of timing, you can either bungle your bike or use the sched module .
It occurred to me to make the chart a file (one file for all devices). And this file will read the script and work on it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question