MyWordCounter is an implementation of the Linux program WC (Word Counter)
This is the first task of the course "Python in the Enterprise", as requested have been implemented the following functions :
- count_lines
- count_words
- count_characters
In order to run the program you only need to install python 3.6.
the execution of the program is quite simple, just run the following command inside the folder where the file MyWordCounter.py is located followed by one of the functions (optional) and obviously the file's path (or simply the filename if this one is located in the same folder of the program).
$ python3 myWC.py [option] <filename>
output : number of lines inside the file
$ python3 myWC.py -l <filename>
output : number of words inside the file
$ python3 myWC.py -w <filename>
output : number of characters inside the file
$ python3 myWC.py -c <filename>
IF NO OPTION IS INDICATED ALL COUNTS WILL BE PRINTED IN THIS ORDER
lines number - words number - characters number
IN CASE OF NO FILE THE PROGRAM READ STANDARD INPUT
to terminate the std input press CTRL+D
In this example we can see the results when no file is indicated as input and it's choosed the option -w (number of words)
$ python3 myWC.py -w
hello this is an example
press ctrl+D to close the standard input
12
$ _
- Marco Amato - other projects