T
T
tmkbl2021-09-03 12:09:10
Python
tmkbl, 2021-09-03 12:09:10

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

3 answer(s)
V
Vindicar, 2021-09-03
@tmkbl

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 .

D
Developer, 2021-09-03
@samodum

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.

What? How will the data file read the script and execute it?

A
Alexander, 2021-09-03
@avorsa

As an option

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question