Simple Excel to CSV converter with merged-cell propagation and cp932 encoding
Project description
xlsx2csv-mergefill
Excelファイル(.xlsx)を、データ処理に適したCSV形式へ変換するPythonライブラリです。 結合セルの補完対応により、業務システムへのデータ取り込みを容易にします。
特徴
- 結合セルの自動補完 — 結合領域を左上セルの値で埋め、データ欠損を防止
- 複数シートの一括変換 — Excelブック内の全シートを安全なファイル名で自動出力
インストール
pip install xlsx2csv-mergefill
使い方
1. ExcelファイルをCSVに一括変換
from xlsx2csv_mergefill import convert_file
# 基本的な使用方法
convert_file("input.xlsx", "output")
# シート名を数値にする場合
convert_file("input.xlsx", "output", use_numeric_sheet_names=True)
→ 複数シートの場合:
- 通常:
<指定パスの拡張子なし>_シート名.csvという形式で同ディレクトリに複数出力されます - 数値オプション使用時:
<指定パスの拡張子なし>_1.csv,<指定パスの拡張子なし>_2.csvという形式で出力されます
単一シートの場合は第2引数で指定したパスに1ファイルをそのまま出力します(拡張子の自動付与は行いません)。
2. 特定シートをPythonリストとして読み込み
from xlsx2csv_mergefill import read_sheet
rows = read_sheet("input.xlsx")
3. 全シートを辞書形式で読み込み
from xlsx2csv_mergefill import read_workbook
data = read_workbook("input.xlsx")
引数
input_path: 入力Excelファイルのパスoutput_path: 出力先のパス。複数シートの場合はプレフィックスとして扱われ、<指定パスの拡張子なし>_シート名.csvを同ディレクトリに出力します。単一シートの場合はこのパスにそのまま出力します(例:out.csvを指定するとout.csvを出力)。use_numeric_sheet_names(オプション):Trueを指定すると、シート名の代わりに数値(1, 2, 3...)を使用してファイル名を生成します。デフォルトはFalse。
戻り値
- 成功時に
0を返します。
例外
FileNotFoundErrorなどの例外を送出することがあります。
制限事項
- 入力形式は
.xlsxのみ対応(.xls非対応) - 出力形式は
UTP-8/ カンマ区切り固定 - 数式セルは計算済みの値として取得されます
ライセンス
本プロジェクトはMITライセンスの下で公開されています。詳細はLICENSEファイルをご覧ください。
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 xlsx2csv_mergefill-1.0.3-py3-none-any.whl.
File metadata
- Download URL: xlsx2csv_mergefill-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4581de46ef09a5c986296c28d788a31dc5ff83f49a083872141c389c21ed5bf1
|
|
| MD5 |
d5962ee6d8c545a666c3307d34d51fd3
|
|
| BLAKE2b-256 |
e6d3e2d159cf85221764e4f0d575c5e4d49e78ccce8b3e9a3f4570fc8158b437
|