Skip to main content

xlsx to csv converter

Project description

xlsx2csv

xlsx to csv converter (http://github.com/dilshod/xlsx2csv)

Converts xlsx files to csv format. Handles large XLSX files. Fast and easy to use.

Tested(supported) python versions:

  • 2.4
  • 2.7
  • 3.4 to 3.12

Installation:

sudo easy_install xlsx2csv

or

pip install xlsx2csv

Also, works standalone with only the xlsx2csv.py script

Usage:

 xlsx2csv.py [-h] [-v] [-a] [-c OUTPUTENCODING] [-s SHEETID]
                   [-n SHEETNAME] [-d DELIMITER] [-l LINETERMINATOR]
                   [-f DATEFORMAT] [--floatformat FLOATFORMAT]
                   [-i] [-e] [-p SHEETDELIMITER]
                   [--hyperlinks]
                   [-I INCLUDE_SHEET_PATTERN [INCLUDE_SHEET_PATTERN ...]]
                   [-E EXCLUDE_SHEET_PATTERN [EXCLUDE_SHEET_PATTERN ...]] [-m]
                   xlsxfile [outfile]

positional arguments:

  xlsxfile              xlsx file path, use '-' to read from STDIN
  outfile               output csv file path, or directory if -s 0 is specified

optional arguments:

  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -a, --all             export all sheets
  -c OUTPUTENCODING, --outputencoding OUTPUTENCODING
                        encoding of output csv ** Python 3 only ** (default: utf-8)
  -s SHEETID, --sheet SHEETID
                        sheet number to convert, 0 for all
  -n SHEETNAME, --sheetname SHEETNAME
                        sheet name to convert
  -d DELIMITER, --delimiter DELIMITER
                        delimiter - columns delimiter in csv, 'tab' or 'x09'
                        for a tab (default: comma ',')
  -l LINETERMINATOR, --lineterminator LINETERMINATOR
                        line terminator - lines terminator in csv, '\n' '\r\n'
                        or '\r' (default: os.linesep)
  -f DATEFORMAT, --dateformat DATEFORMAT
                        override date/time format (ex. %Y/%m/%d)
  --floatformat FLOATFORMAT
                        override float format (ex. %.15f)
  -i, --ignoreempty     skip empty lines
  -e, --escape          Escape \r\n\t characters
  -p SHEETDELIMITER, --sheetdelimiter SHEETDELIMITER
                        sheet delimiter used to separate sheets, pass '' if
                        you do not need delimiter, or 'x07' or '\\f' for form
                        feed (default: '--------')
  -q QUOTING, --quoting QUOTING
                        field quoting, 'none' 'minimal' 'nonnumeric' or 'all' (default: 'minimal')
  --hyperlinks, --hyperlinks
                        include hyperlinks
  -I INCLUDE_SHEET_PATTERN [INCLUDE_SHEET_PATTERN ...], --include_sheet_pattern INCLUDE_SHEET_PATTERN [INCLUDE_SHEET_PATTERN ...]
                        only include sheets named matching given pattern, only
                        effects when -a option is enabled.
  -E EXCLUDE_SHEET_PATTERN [EXCLUDE_SHEET_PATTERN ...], --exclude_sheet_pattern EXCLUDE_SHEET_PATTERN [EXCLUDE_SHEET_PATTERN ...]
                        exclude sheets named matching given pattern, only
                        effects when -a option is enabled.
  -m, --merge-cells     merge cells

Usage with folder containing multiple xlxs files:

    python xlsx2csv.py /path/to/input/dir /path/to/output/dir

will output each file in the input dir converted to .csv in the output dir. If omitting the output dir it will output the converted files in the input dir

Usage from within Python:

  from xlsx2csv import Xlsx2csv
  Xlsx2csv("myfile.xlsx", outputencoding="utf-8").convert("myfile.csv")

Expat SAX parser used for xml parsing.

See alternatives:

Bash: http://kirk.webfinish.com/?p=91

Python: http://github.com/staale/python-xlsx http://github.com/leegao/pyXLSX

Ruby: http://roo.rubyforge.org/

Java: http://poi.apache.org/

Meta

Dilshod Temirkhdojaev – tdilshod@gmail.com

Distributed under the MIT LICENSE. See LICENSE for more information.

https://github.com/dilshod

Download files

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

Source Distribution

xlsx2csv-0.8.3.tar.gz (221.4 kB view details)

Uploaded Source

Built Distribution

xlsx2csv-0.8.3-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file xlsx2csv-0.8.3.tar.gz.

File metadata

  • Download URL: xlsx2csv-0.8.3.tar.gz
  • Upload date:
  • Size: 221.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for xlsx2csv-0.8.3.tar.gz
Algorithm Hash digest
SHA256 6c65d5989e8d3f14dd7296d425d693a67f51899d0c8e1ed7bcbf9ccb18223734
MD5 7c8eb7b0a7fb913fc982b7b37dd43cae
BLAKE2b-256 04e3e795ae3b9d76e9195987c4b57c7bb58ab07c0886e6462b4142ae1c1b8143

See more details on using hashes here.

File details

Details for the file xlsx2csv-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: xlsx2csv-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for xlsx2csv-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2cefc2899301f9328f0136fa00e9c4b07b69f255d6bbbc7f759254877e3a106
MD5 c33e025cfca39f038bacf80d17d84a5d
BLAKE2b-256 df07e2426bbb446152e63752cd384fd39b80ed1390e6d127d30c98968f6d4875

See more details on using hashes here.

Supported by

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