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
Metadata
Release files for oect-excel-processor 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| oect_excel_processor-0.1.0.tar.gz | 12.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oect_excel_processor-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.3 kB
Release files / oect_excel_processor-0.1.0.tar.gz
| Download URL | oect_excel_processor-0.1.0.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d30e4f6deaa42f6c2fe489758cf65afc37aa9aab039c9586d16e1f5decbc7b7e
|
|
BLAKE2b-256 checksum How to use checksums |
e1529fe903a6f1b8de788a6113536b68aa6972a334db28600abb5b8e1141f6ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / oect_excel_processor-0.1.0-py3-none-any.whl
| Download URL | oect_excel_processor-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
305d52b173f9a5fe5179b3ebf5a8d0a6e23247c3378c9ee17a80199208f01927
|
|
BLAKE2b-256 checksum How to use checksums |
a0ced5c8880d3d4d3fc0565cb8ea11ef785ed6d86910d0397f8c93976aed71c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for oect-excel-processor 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.