This Python script processes a series of Excel files in a specified directory, extracting and compiling data into a CSV file. It also generates a detailed log file in CSV format, capturing various information and error messages encountered during the data extraction process.
-
Create a Virtual Environment (Recommended):
- Navigate to your project directory in the terminal.
- Run
python -m venv venv
to create a virtual environment namedvenv
. - Activate the virtual environment:
- Windows:
.\venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
-
Install Required Libraries:
- Run
pip install -r requirements.txt
to install the required libraries.
- Run
- Place the script in your project directory.
- Ensure the Excel files to be processed are in a directory named
submissoes
in the same location as the script. - Run the script using
python main.py
.
- The script generates a log file named
log_file.csv
. - The log file contains entries for various events and errors encountered during processing, such as:
- Missing or empty sheets in the Excel files.
- Invalid data, such as out-of-range values in specific columns.
- File read errors or other exceptions.
- Each entry in the log file includes a timestamp, file name, school name (if applicable), error type (INFO/WARN/ERROR), and a descriptive message.
- The compiled data is saved in a file named
paper_prepare.csv
. - The data from different sheets of each Excel file is combined into this single CSV file, with appropriate headers and formatting.