Download preprocess2.py from wolfvoid/SpatiotemporalPredictionHuNan: direct link, hf CLI and curl.
- Browser
- Download file 891 Bytes
-
https://huggingface.co/datasets/wolfvoid/SpatiotemporalPredictionHuNan/resolve/main/preprocess2.py
- Command line
-
hf download hf://datasets/wolfvoid/SpatiotemporalPredictionHuNan/preprocess2.py
-
curl -L -o preprocess2.py https://huggingface.co/datasets/wolfvoid/SpatiotemporalPredictionHuNan/resolve/main/preprocess2.py
891 Bytes
| import os | |
| import pandas as pd | |
| def save_csv_files(folder_path): | |
| # 遍历文件夹及其子文件夹 | |
| for root, dirs, files in os.walk(folder_path): | |
| for filename in files: | |
| # 检查文件是否为CSV文件 | |
| if filename.endswith(".csv"): | |
| file_path = os.path.join(root, filename) | |
| try: | |
| # 读取CSV文件 | |
| df = pd.read_csv(file_path) | |
| # 重新保存CSV文件(覆盖原文件) | |
| df.to_csv(file_path, index=False, encoding="utf-8-sig") | |
| print(f"Re-saved file: {file_path}") | |
| except Exception as e: | |
| print(f"Error processing file {file_path}: {e}") | |
| # 指定要处理的文件夹路径 | |
| folder_path = input("请输入要处理的文件夹路径:") | |
| save_csv_files(folder_path) |