https://github.com/tomasfn87/randomize
(( Use it on Google Colab: click the link below )) Python script that takes a JSON with a list and a JSON with the last result; by default it will choose an item from the list, avoiding the last result, but it can also select each item of the list once and generate a log file.
https://github.com/tomasfn87/randomize
google-colab-notebook json-logs list python3 randomizer
Last synced: about 1 month ago
JSON representation
(( Use it on Google Colab: click the link below )) Python script that takes a JSON with a list and a JSON with the last result; by default it will choose an item from the list, avoiding the last result, but it can also select each item of the list once and generate a log file.
- Host: GitHub
- URL: https://github.com/tomasfn87/randomize
- Owner: tomasfn87
- License: gpl-3.0
- Created: 2024-03-01T02:50:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-26T01:55:37.000Z (about 1 year ago)
- Last Synced: 2025-04-26T02:57:10.559Z (about 1 year ago)
- Topics: google-colab-notebook, json-logs, list, python3, randomizer
- Language: Python
- Homepage: https://colab.research.google.com/drive/1kAGGr3dOY30sIOwSJn89dm8s0IAjpJx7?usp=sharing
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Randomize
- Python script that takes a JSON with a list and a JSON with the last result; it will choose an item from the list, avoiding the last result.
## How to use
```console
python3 randomize.py
```
- 1. Run the command above to create initial JSON files;
- 2. Edit `listToRandomize.json` with the result description and the data you need to randomize;
- 3. Run the command above again and the result will be printed to the screen.
### `--loop` option
```console
python3 randomize.py --loop 3
```
- The `--loop n` flag allows the program to be executed `n` times (`n` must be an integer).
### `--no-repeat` option
```console
python3 randomize.py --no-repeat
```
- Running the program with the flag `--no-repeat` will make it avoid all items that were already selected until the whole list is over;
- This option will also generate a nice log of the program execution in the file `alreadyRandomized.json`, thus generating an automatic report of an activity or process that needs random sorting to function.
### How to backup a randomization session's data
- Scripts `save_result_as_JSON.sh` and `save_result_as_MD.sh` read data from the session JSON files and save it to the corresponding file format, allowing the session data to backed up.
#### Permissions
```console
chmod +x save_result_as_{JSON,MD}.sh
```
- First add execution permission to the scripts.
---
#### As `.json`
```
./save_result_as_JSON.sh 'file_name'
```
- If `jq` is installed the result will be printed to the screen;
- Install it on `Debian` systems with
```console
sudo apt install -y jq
```
---
#### As `.md`
```
./save_result_as_MD.sh 'file_name'
```