Skip to main content

Convert Excel files to delimited text

Project description

excel2txt

Convert Excel files to delimited text

Synopsis

For usage, run excel2txt --help:

usage: excel2txt [-h] [-o str] [-d str] [-D] [-n] [--version] FILE [FILE ...]

Convert Excel files to delimited text

positional arguments:
  FILE                  Input Excel file(s)

optional arguments:
  -h, --help            show this help message and exit
  -o str, --outdir str  Output directory (default:
                        /Users/kyclark/work/python/excel2txt-py)
  -d str, --delimiter str
                        Delimiter for output file (default: )
  -D, --mkdirs          Create separate directories for output files (default:
                        False)
  -n, --normalize       Normalize headers (default: False)
  --version             show program's version number and exit

Given one or more Excel files as positional parameters, the program will create an output text file in the given output directory (which defaults to the current working directory).

For example:

$ excel2txt tests/test1.xlsx
  1: tests/test1.xlsx
Done, see output in "/Users/kyclark/work/python/excel2txt-py".

Now you should have a file called "test1__sheet1.txt" in the current directory. You could use the "csvchk" program to see the structure of this file:

$ csvchk test1__sheet1.txt
// ****** Record 1 ****** //
name          : Ed
rank          : Captain
serial_number : 12345

If you are processing multiple files, you might find the "--mkdirs" option useful to put all the sheets from each workbook into a separate directories:

$ ./excel2txt.py tests/*.xlsx --outdir out --mkdirs
  1: tests/test1.xlsx
  2: tests/test2.xlsx
Done, see output in "/Users/kyclark/work/python/excel2txt-py/out".

In the "out" directory, there will be "test1" and "test2" directories:

$ find out -type f
out/test1/test1__sheet1.txt
out/test2/test2__sheet1.txt

You can use the "--delimiter" option to change the output file delimiter.

Column, file normalization

The "--normalize" option will alter the headers of each output file to lowercase values and remove non-alphanumeric characters or the underscore. This will also break "CamelCase" values into "snake_case."

This same normalization will be used to create the output file names so as to avoid any possibility of creating output files with illegal or difficult characters.

See also

csvkit, csvchk

Author

Ken Youens-Clark kyclark@gmail.com

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

excel2txt-0.2.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

excel2txt-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file excel2txt-0.2.0.tar.gz.

File metadata

  • Download URL: excel2txt-0.2.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for excel2txt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 06fd8409a5d44ee09e7962a105ce14bba014e0f2cfc166c73dadb5abfb6f8f99
MD5 253e8d7e9597a988c7694afd8860e5db
BLAKE2b-256 b0bba309a34fa79354546251b229ce18ba645df9e117b7f6487c952672687bf3

See more details on using hashes here.

File details

Details for the file excel2txt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: excel2txt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for excel2txt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2df5038b363b0ffa1dea295adf84d33c2baa6860ec1b87920a10c83ca98dee3
MD5 a352fde38af52a32d32dfd76847f6acb
BLAKE2b-256 a89d60f4f3ed1b9516a415dfc32deef4ce858a112cc1d93252e3e251ce5a3be5

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