https://github.com/bradleyhurley/ccount
A Python column count utility
https://github.com/bradleyhurley/ccount
ccount click libmagic python-utilities
Last synced: 11 months ago
JSON representation
A Python column count utility
- Host: GitHub
- URL: https://github.com/bradleyhurley/ccount
- Owner: bradleyhurley
- Created: 2016-08-12T10:47:10.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-04T19:30:39.000Z (about 8 years ago)
- Last Synced: 2025-06-05T22:39:37.977Z (12 months ago)
- Topics: ccount, click, libmagic, python-utilities
- Language: Python
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ccount
A Python utility that will return the number of columns from standard in, text, gzip, or bzip files to standard out using magic to inspect the files MIME Type.
### Magic Dependencies
On Windows, copy magic1.dll, regex2.dll, and zlib1.dll onto your PATH from the Binaries and Dependencies zipfiles provided by the [File for Windows](http://gnuwin32.sourceforge.net/packages/file.htm) project. You will need to copy the file `magic` out of `[binary-zip]\share\misc`, and pass it's location to `Magic(magic_file=...)`
On OSX:
- When using Homebrew: `brew install libmagic`
- When using macports: `port install file`
## Configuration
* Create virtualenv
* pip install -r requirements.txt
## Usage
> python ccount --help
```
Options:
--input FILENAME The file to read as input or '-'for standard in. Default = '-'
--delimiter TEXT The file delimiter. Default='|'
--help Show this message and exit.
```
You can also add ccount to your path to run from your terminal.
> ./ccount --help
```
Options:
--input FILENAME The file to read as input or '-'for standard in. Default = '-'
--delimiter TEXT The file delimiter. Default='|'
--help Show this message and exit.
```
## Examples
`> cat sample_file | ./ccount`
4
`> python ccount --input sample_file`
4
## Other
You could always use awk to get the same result, but I wanted to work on a simple project and use Click for command line arguments.
`> awk -F '|' '{print NF}' sample_file`
4