Skip to main content

No project description provided

Project description

PyPI version

cutpaste

Unix-like cut and paste commands with multi-character delimiter support.

Unlike the standard Unix cut which only supports single-character delimiters, pycut and pypaste can split and join on strings like ::, ->, or any delimiter you need.

Installation

pip install cutpaste

pycut - Extract fields from lines

Extract specific fields from each line of input, using a delimiter.

pycut -d DELIMITER -f FIELDS [FILE...]

Options:

  • -d, --delimiter - String delimiter to split on (default: TAB). Supports escape sequences like \t, \n.
  • -f, --field - Field(s) to extract (required). 1-based indexing.
  • -v, --version - Show version and exit.

Field specification formats:

  • Single field: -f 2 (extract field 2)
  • Multiple fields: -f 1,3,5 (extract fields 1, 3, and 5)
  • Range: -f 2-4 (extract fields 2, 3, and 4)
  • Mixed: -f 1,3-5,7 (extract fields 1, 3, 4, 5, and 7)

Examples:

# Extract the second field from a space-delimited file
pycut -d ' ' -f 2 data.txt

# Extract first and third columns from CSV
pycut -d ',' -f 1,3 data.csv

# Multi-character delimiter - extract second part of "key::value" lines
pycut -d '::' -f 2 config.txt

# Use with pipes
echo "a->b->c" | pycut -d '->' -f 2
# Output: b

# Extract a range of fields
echo "one,two,three,four,five" | pycut -d ',' -f 2-4
# Output: two,three,four

# Read from stdin explicitly
cat file.txt | pycut -d '\t' -f 1 -

pypaste - Merge files line by line

Merge corresponding lines from multiple files, joining them with a delimiter.

pypaste -d DELIMITER [FILE...]

Options:

  • -d, --delimiter - String delimiter to join with (default: TAB). Supports escape sequences like \t, \n.
  • -v, --version - Show version and exit.

Examples:

# Merge two files with tab delimiter (default)
pypaste names.txt ages.txt

# Merge with comma delimiter
pypaste -d ',' col1.txt col2.txt col3.txt

# Multi-character delimiter
pypaste -d ' | ' left.txt right.txt

# Use stdin as one of the inputs
seq 5 | pypaste -d ',' - letters.txt

Streaming

Both commands process input line-by-line without loading entire files into memory. This means they work efficiently with:

  • Large files
  • Piped input
  • Infinite streams

License

MIT

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

cutpaste-0.0.3.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

cutpaste-0.0.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file cutpaste-0.0.3.tar.gz.

File metadata

  • Download URL: cutpaste-0.0.3.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cutpaste-0.0.3.tar.gz
Algorithm Hash digest
SHA256 43a21be6534728bb708562298e66bd418716ba269e211186d7317efe24f4139f
MD5 7da3485d174c745ffeb97b251f1b507d
BLAKE2b-256 c384945f18dc637f1b0f91847efecaf6e8875c85f0f32eac706ebf0c3e7accaa

See more details on using hashes here.

File details

Details for the file cutpaste-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: cutpaste-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cutpaste-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 150e851ccbb45c2e8e32a89240a3d8cf58f4d1c6ce67bf54b47fc865e6297372
MD5 b7330e29aa08259a6bd4cfb8f7569563
BLAKE2b-256 9f2e5becd7b11b1949c2bdc102e8ad9941492fc610603cde79769bc5b488bff3

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