Skip to main content

Application that takes a string or file and returns the number of all characters in the string or file occurring only once.

Project description

Single char counter

Installation

Clone this repository to your local machine:

pip install single-char-counter-by-ng

Use the package manager pip to install requirements:

pip install -r requirements.txt

Summary

Application that takes a string or file and returns the number of all characters in the string or file occurring only once. The function was tested using pytest. The function is in the single_char_counter_by_ng folder and the tests are in the tests folder. The test_count_single_char folder contains tests and parameterized data. For convenience, some __init__ already have modules imported.

Usage

from single_char_counter_by_ng import (count_single_char, 
                                       count_single_char_in_file)

count_single_char('HelLo') # ---> 5

count_single_char('HelLo', case_insensitive=True) # ---> 3

# file.txt ---> 'HelLo'
count_single_char_in_file('path_to_file/file.txt') # ---> 5

count_single_char_in_file('path_to_file/file.txt', case_insensitive=True) # ---> 3

Also implemented command-line interface(CLI):

python count_single_char.py --string “your string”
python count_single_char.py -s “your string”

or

python count_single_char.py --file "path_to_text_file"
python count_single_char.py -f "path_to_text_file"

There is also a "-i" parameter that can be specified so that the result is case insensitive:

python count_single_char.py -s “your string” -i

If you passed two parameters, the parameter '--file' have higher priority:

python collect_framework.py  --string “your string” --file path_to_text_file

Used

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

single_char_counter_by_ng-1.1.10.tar.gz (37.7 kB view details)

Uploaded Source

File details

Details for the file single_char_counter_by_ng-1.1.10.tar.gz.

File metadata

File hashes

Hashes for single_char_counter_by_ng-1.1.10.tar.gz
Algorithm Hash digest
SHA256 084bf91e62798bfc02e4c423715bc13ecf761a13ee5e7ca11b9ac9e7c7b691d5
MD5 449890edf49f1005d6cdb950ceac9c56
BLAKE2b-256 14d4240fe7e06a7e2d6d8f176133074519ce858596ed67f05b0ca40f56b31a45

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