Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlossanabriam/excel-transformer-script
A Python script for modifying Excel files, setting values to 0 when a value < 100 is found
https://github.com/carlossanabriam/excel-transformer-script
Last synced: 2 days ago
JSON representation
A Python script for modifying Excel files, setting values to 0 when a value < 100 is found
- Host: GitHub
- URL: https://github.com/carlossanabriam/excel-transformer-script
- Owner: CarlosSanabriaM
- Created: 2024-05-22T09:59:32.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-08-18T21:12:53.000Z (5 months ago)
- Last Synced: 2024-08-19T21:05:02.731Z (5 months ago)
- Language: Python
- Size: 448 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Excel transformer script
![Transformation example](docs/transformation-example.png)
This project is a Python-based tool designed to modify Excel files through a terminal-based user interface.
Utilizing the `openpyxl` library for Excel file manipulations and the [textual](https://github.com/Textualize/textual/tree/main) library
for creating an interactive terminal UI, the script performs specific data transformations while preserving cell formatting and colors.
The user interface guides the user to input the necessary parameters, streamlining the transformation process for enhanced usability.The transformations are implemented using an Strategy design pattern. Currently, there are 2 strategies:
* `SetZeroWhenNumberLowerThanAbsoluteValueStrategy`: It adjusts integer and percentage pairs in the spreadsheet,
setting values below 100 to zero and marking these changes with red text.
* `SetZeroWhenNumberLowerThanRelativeValueStrategy`: Sets to zero the percentage value in pairs of columns when the integer value
relative to the count column (in percentage) is less than a relative value (in percentage).## Steps to execute
There are 2 scripts:
* `script.py`: Only contains the Excel transformation logic. If you don't want to interact with the UI, you can use this script.
1. Edit the following variables inside the script:
- `input_excel_file`: Name of the input excel file (example: `input.xlsx`)
- `output_excel_file`: Name of the output excel file (example: `output.xlsx`)
- `start_column_name`: Name of the first column from which transformations should be made (example: `Eventos GFP+ (CD45+)`)
2. Execute the script with the following commands:
```shell
pipenv shell
pip install openpyxl
python script.py
```
* `script-ui.py`: Uses `textual` library to show a UI inside the terminal, improving user experience.
1. Execute the script with the following commands:
```shell
pipenv shell
pip install openpyxl textual
python script-ui.py
```
2. Specify the values that the UI asks for## UI Screenshots
## Improve UI appearance in MacOs terminal
In order to achieve the same visual appearance as the screenshots above, you may need to adjust the terminal settings on MacOs.
Follow the steps detailed in the following `textual` FAQ question:
[Why doesn't Textual look good on macOS?](https://textual.textualize.io/FAQ/#why-doesnt-textual-look-good-on-macos)