Skip to main content

csv_to_xls

Install

pip install csv_to_xls

How to use

When you install csv_to_xls you will get a cli tool named csv2xls:

!csv2xls --help
usage: csv2xls [-h] [--file_glob FILE_GLOB] [--out_file OUT_FILE] [--recursive]
               [--delimiter DELIMITER] [--quotechar QUOTECHAR] [--symlinks]
               [--file_re FILE_RE] [--folder_re FOLDER_RE]
               [--skip_file_glob SKIP_FILE_GLOB] [--skip_file_re SKIP_FILE_RE]
               [--skip_folder_re SKIP_FOLDER_RE]
               path

Convert csv file(s) into an excel file, if multiple csvs put on tabs.

positional arguments:
  path                             path to searching for *.csv files

optional arguments:
  -h, --help                       show this help message and exit
  --file_glob FILE_GLOB            Only include files matching glob (default:
                                   *.csv)
  --out_file OUT_FILE              output excel file (default: output.xlsx)
  --recursive                      search subfolders (default: False)
  --delimiter DELIMITER            delimiter to use (default: ,)
  --quotechar QUOTECHAR            quote character to escape the delimiter
                                   (default: ")
  --symlinks                       follow symlinks? (default: False)
  --file_re FILE_RE                Only include files matching regex
  --folder_re FOLDER_RE            Only enter folders matching regex
  --skip_file_glob SKIP_FILE_GLOB  Skip files matching glob
  --skip_file_re SKIP_FILE_RE      Skip files matching regex
  --skip_folder_re SKIP_FOLDER_RE  Skip folders matching regex,

Example

Consider the below csv files:

!ls _tests/
addresses.csv biostats.csv  faithful.csv  hw_200.csv    tally_cab.csv

To merge these csvs into one excel file named merged.xlsx:

!csv2xls _tests/ --out_file merged.xlsx

We can see there is a worksheet for each filename:

import pandas as pd
pd.ExcelFile('merged.xlsx').sheet_names
['addresses', 'biostats', 'hw_200', 'tally_cab', 'faithful']

Let’s say we want to skip the biostats.csv file, we can use the --skip_file_re arg:

!rm -f merged.xlsx
!csv2xls _tests/ --out_file merged.xlsx --skip_file_re 'biostats*'

Now that particular sheet is not there:

pd.ExcelFile('merged.xlsx').sheet_names
['addresses', 'hw_200', 'tally_cab', 'faithful']

Metadata

Release files for csv-to-xls 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv-to-xls 0.0.4
File Size Uploaded
csv_to_xls-0.0.4.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csv-to-xls 0.0.4
File Interpreter ABI Platform
csv_to_xls-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / csv_to_xls-0.0.4.tar.gz

Download URL csv_to_xls-0.0.4.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9b382e940a1ead42241f31cf153a9551189bd85565d26062362fdcc27407c9e6
BLAKE2b-256 checksum
How to use checksums
98bb687ea37fdaa4a7c74494a800b428b4ec8c831a7eb76a485cabc8eb86939f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / csv_to_xls-0.0.4-py3-none-any.whl

Download URL csv_to_xls-0.0.4-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52c7ab6216e3b2f65d5456fcf4d25ec5fb23df030a0fadf77c34c68f24f06718
BLAKE2b-256 checksum
How to use checksums
6dd6ba97ff263097b545567a27c8438c203be58d4d15f497143b7bde0fe63082
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page