Skip to main content

Convert file format with pandas

Project description

convert-fileformat-with-pandas

Convert file format with pandas.

Python application PyPI version Python Versions

Requirements

  • Python 3.11+

Install

$ pip install convpandas

https://pypi.org/project/convpandas/

Usage

csv2xlsx

Convert csv file to xlsx file.

$ convpandas csv2xlsx --help
usage: convpandas csv2xlsx [-h] [--sep SEP] [--encoding ENCODING] [--quotechar QUOTECHAR] [--numeric_to_string] [--sheet_name SHEET_NAME [SHEET_NAME ...]]
                           csv_files [csv_files ...] xlsx_file

positional arguments:
  csv_files

  xlsx_file

optional arguments:
  -h, --help            show this help message and exit

  --sep SEP             Delimiter to use when reading csv. (default: ,)

  --encoding ENCODING   Encoding to use when reading csv. List of Python standard encodings.
                        https://docs.python.org/3/library/codecs.html#standard-encodings (default: utf-8)

  --quotechar QUOTECHAR
                        The character used to denote the start and end of a quoted item when reading csv. (default: ")

  --numeric_to_string   If specified, write numeric value as string type. If not specified, write numeric value as numeric type. (default: False)

  --sheet_name SHEET_NAME [SHEET_NAME ...]

Convert in.csv to out.xlsx .

$ convpandas csv2xlsx in.csv out.xlsx

When CSV_FILE is - , STDIN is used for input.

$ convpandas csv2xlsx - out.xlsx < in.csv

Convert in1.csv and in2.csv to out.xlsx . Sheet name is csv filename without its' suffix.

$ convpandas csv2xlsx in1.csv in2.csv out.xlsx

If --sheet_name is specified, sheet name is set.

$ convpandas csv2xlsx in1.csv in2.csv out.xlsx --sheet_name foo bar

xlsx2csv

Convert xlsx file to csv file.

$ convpandas xlsx2csv --help
usage: convpandas xlsx2csv [-h] [--sheet_name SHEET_NAME] [--sep SEP] [--encoding ENCODING] [--quotechar QUOTECHAR] xlsx_file csv_file

positional arguments:
  xlsx_file

  csv_file

optional arguments:
  -h, --help            show this help message and exit

  --sheet_name SHEET_NAME
                        Sheet name when reading xlsx. If not specified, read 1st sheet. (default: None)

  --sep SEP             Field delimiter for the output file. (default: ,)

  --encoding ENCODING   A string representing the encoding to use in the output file. (default: utf-8)

  --quotechar QUOTECHAR
                        Character used to quote fields. (default: ")

Convert in.xlsx to out.csv .

$ convpandas csv2xlsx in.xlsx out.csv

When CSV_FILE is - , write to STDOUT.

$ convpandas csv2xlsx in.xlsx -
name,age
Alice,23

With specifying --sheet_name, you can select sheet name that you want to convert.

$ convpandas csv2xlsx in.xlsx out.csv --sheet_name sheet2

Usage for Developer

Refer to https://github.com/kurusugawa-computer/convert-fileformat-with-pandas/blob/main/README_for_developer.md .

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

convpandas-0.3.6.tar.gz (64.0 kB view details)

Uploaded Source

Built Distribution

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

convpandas-0.3.6-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file convpandas-0.3.6.tar.gz.

File metadata

  • Download URL: convpandas-0.3.6.tar.gz
  • Upload date:
  • Size: 64.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for convpandas-0.3.6.tar.gz
Algorithm Hash digest
SHA256 0a027ac11695b3c0c1f199b15b9ad20735345692f57ab71551019384f0bfd167
MD5 b4a9e5aa5bda7d689c19ea829bf5c82d
BLAKE2b-256 71c0934a6b869ee2d144bf5bfe2ee0f72ab6496fd2d0ad5a039348eb59e52e1a

See more details on using hashes here.

File details

Details for the file convpandas-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: convpandas-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for convpandas-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ba193b1229cb7d4a694f88d1fd388df8da824ff0fef32b0870ab7dfee462e045
MD5 46f12aa4bb15177faa61cc2219470325
BLAKE2b-256 d89f130cfb90fc86c6201b5fe9576e9020ecff67682bbd084294e706d4f9a039

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