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)

→ 複数シートの場合:

  • 通常:<指定パスの拡張子なし>_シート名.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


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.4.tar.gz (6.6 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.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xlsx2csv_mergefill-1.0.4.tar.gz
  • Upload date:
  • Size: 6.6 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.4.tar.gz
Algorithm Hash digest
SHA256 8fd7909558ce74c8b7b9199a5b770d3175edad1097c1da4bef9bed3f7d599bc8
MD5 dffa4018deb490caf46f45aac9159ea5
BLAKE2b-256 12f9d41506c2ad07416e9b57be04748eae91a3ab4fa0d68f6125352c82751eb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlsx2csv_mergefill-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 73c5af936cef8bf2869af32192f3fee8f8be6676c2c5f5c008bbc30a60f5568e
MD5 a15ccad7cf61f9f9830516e06699ddbf
BLAKE2b-256 9302a3d54c80aea15ab1283e5b942fc281fc7b71d6a2f77005254bef3702cd3a

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