处理OECT性能测试后的Excel数据并转换为CSV格式
Project description
OECT Excel Processor
用于处理OECT(有机电化学晶体管)性能测试后的Excel数据并转换为CSV格式的Python包。
功能特点
- 支持两种类型的工作表处理:
transfer类型:从第三行开始有字段名,共四列数据transient类型:第三行前两列是字段名,数据按每两列一组排列,需要合并
- 可以处理包含多个工作表的Excel文件
- 自动将每个工作表转换为单独的CSV文件
- 支持自定义输出文件名前缀
- 自动去除transient类型工作表中的空行和不完整数据行
- 支持批量处理多个Excel文件,并按自然排序处理
- 支持多核并行处理,加速批量文件处理
- 提供命令行工具,方便直接使用
安装
从PyPI安装
pip install oect-excel-processor
从源码安装
git clone https://github.com/Durian-leader/oect-excel-processor.git
cd oect-excel-processor
pip install -e .
使用方法
作为Python库使用
单个Excel文件处理
from oect_excel_processor import ExcelProcessor
# 创建处理器实例
excel_file = "your_excel_file.xls"
sheet_types = ["transfer", "transient", "transfer", "transfer"]
output_prefix = "output"
processor = ExcelProcessor(excel_file, sheet_types, output_prefix)
saved_files = processor.process_and_save()
print("保存的CSV文件:")
for file in saved_files:
print(f"- {file}")
批量处理Excel文件
from oect_excel_processor import BatchExcelProcessor
# 创建批处理器实例
batch_processor = BatchExcelProcessor(
directory="your_directory",
file_pattern="*.xls",
sheet_types=["transfer", "transient"],
output_prefix="batch_output"
)
# 使用多核处理加速
results = batch_processor.process_all_files(
output_dir="csv_output",
use_multiprocessing=True, # 启用多进程处理
max_workers=None # 自动使用所有可用CPU核心
)
# 获取处理摘要
summary = batch_processor.get_processing_summary(results)
print(f"总Excel文件数: {summary['total_excel_files']}")
print(f"成功处理的文件数: {summary['successful_files']}")
print(f"生成的CSV文件总数: {summary['total_csv_files']}")
作为命令行工具使用
安装后,可以使用oect-processor命令行工具:
处理单个文件
oect-processor single your_excel_file.xls --sheet-types transfer,transient --output-prefix output
批量处理文件
oect-processor batch your_directory --pattern "*.xls" --sheet-types transfer,transient --output-prefix batch_output --output-dir csv_output --multiprocessing
工作表类型说明
transfer类型
- 从第三行开始,第三行包含字段名
- 总共有四列数据
- 从第四行开始是实际数据
transient类型
- 第三行的前两列是字段名
- 数据按每两列一组排列(AB, CD, EF等)
- 每组的数据应该连接在一起
- 从第四行开始是实际数据
- 自动去除空行和不完整的数据行
输出文件
输出的CSV文件将按照以下格式命名:
{output_prefix}-{sheet_index}-{sheet_type}.csv
例如,如果output_prefix设置为"data",则输出文件将为:
- data-1-transfer.csv
- data-2-transient.csv
- 等等
对于批处理,输出文件名格式为:
{output_prefix}-{file_index}-{sheet_index}-{sheet_type}.csv
示例
包中提供了几个示例脚本,展示如何使用该包:
single_file_example.py: 展示如何处理单个Excel文件batch_processing_example.py: 展示如何批量处理Excel文件multiprocessing_comparison.py: 展示多核处理与单核处理的性能对比
许可证
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oect_excel_processor-0.1.0.tar.gz.
File metadata
- Download URL: oect_excel_processor-0.1.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d30e4f6deaa42f6c2fe489758cf65afc37aa9aab039c9586d16e1f5decbc7b7e
|
|
| MD5 |
051a904e257c77b8366dc8470f8b7f57
|
|
| BLAKE2b-256 |
e1529fe903a6f1b8de788a6113536b68aa6972a334db28600abb5b8e1141f6ce
|
File details
Details for the file oect_excel_processor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: oect_excel_processor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
305d52b173f9a5fe5179b3ebf5a8d0a6e23247c3378c9ee17a80199208f01927
|
|
| MD5 |
01ac390d4b281356973703503628ed42
|
|
| BLAKE2b-256 |
a0ced5c8880d3d4d3fc0565cb8ea11ef785ed6d86910d0397f8c93976aed71c1
|