/
Walmet
/
CTF
Обзор
Документация
Войти
/
Walmet
/
CTF
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/components/document_handler.py
30 строк
1 KB
Maksim Goncharov
add edit cell functionality
14 дек 2025, 16:51
14 дек 2025, 16:51
9a7487c
Код
Авторство
О чём код?
import pandas as pd import os from typing import Optional class DocumentHandler: def load_csv_document(self, file_path: str) -> Optional[pd.DataFrame]: """ Loads a single CSV file into a pandas DataFrame. Returns the DataFrame or None if an error occurs. """ if not os.path.exists(file_path): print(f"File not found: {file_path}") return None try: df = pd.read_csv(file_path, index_col=None, dtype=str) print(f"File '{file_path}' successfully loaded.") return df except Exception as e: print(f"Error loading file {file_path}: {e}") return None def save_dataframe_to_csv(self, df: pd.DataFrame, output_path: str): """ Saves a DataFrame to the specified CSV file. """ try: df.to_csv(output_path, index=False) print(f"Table successfully saved to {output_path}") except Exception as e: print(f"Error saving file {output_path}: {e}")