Skip to main content

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)

# 非表示シートも含めて出力する場合
convert_file("input.xlsx", "output", include_hidden_sheets=True)

→ 出力形式:

  • 通常:<指定パスの拡張子なし>_シート名.csv という形式で同ディレクトリに出力されます
  • 数値オプション使用時:<指定パスの拡張子なし>_0.csv, <指定パスの拡張子なし>_1.csv という形式で出力されます

※ 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 を同ディレクトリに出力します。
  • use_numeric_sheet_names (オプション): True を指定すると、シート名の代わりに数値(0, 1, 2...)を使用してファイル名を生成します。デフォルトは False
  • include_hidden_sheets (オプション): True を指定すると、非表示シートも含めて出力します。デフォルトは False(非表示シートは出力しない)。

戻り値

  • 成功時に 0 を返します。

例外

  • FileNotFoundError などの例外を送出することがあります。

制限事項

  • 入力形式は .xlsx のみ対応(.xls 非対応)
  • 出力形式は UTP-8 / カンマ区切り固定
  • 数式セルは計算済みの値として取得されます

ライセンス

本プロジェクトはMITライセンスの下で公開されています。詳細はLICENSEファイルをご覧ください。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xlsx2csv_mergefill-1.0.5.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xlsx2csv_mergefill-1.0.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file xlsx2csv_mergefill-1.0.5.tar.gz.

File metadata

  • Download URL: xlsx2csv_mergefill-1.0.5.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for xlsx2csv_mergefill-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5f05474598f9c3eae0c11c959350fba881c333a9cea3fb02b772a09eb4a1c606
MD5 700ceae46d9458065fa57539e91e1306
BLAKE2b-256 e83dd5de2e6de3714e3ad94f352f4454d64765e984cd845aa8dca6a8d2c49fea

See more details on using hashes here.

File details

Details for the file xlsx2csv_mergefill-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for xlsx2csv_mergefill-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 795c05c7ace509587fa9f12d02c132314883fa4975ea756d43f6782722421a9e
MD5 1f953754e6db824df3323f4fc569dcb4
BLAKE2b-256 b03523d519f6e93113efd7d2d0056adde691a06f4713c20d49d37fbb57a50040

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page