From 44583d6929d6e4b0bab528f3ccf625af6364f617 Mon Sep 17 00:00:00 2001 From: justjcurtis Date: Fri, 5 Jul 2019 11:58:32 +0100 Subject: [PATCH 1/3] added -id option for setting input delimiter --- lcNrD.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lcNrD.py b/lcNrD.py index 918c285..a6d6cec 100644 --- a/lcNrD.py +++ b/lcNrD.py @@ -12,6 +12,8 @@ help='** this is the file you\'re targeting to get the lcNrD treatment') parser.add_argument("-o", "--out", type=str, help='this is the file you want the lcNrD file to output as. Default = same name + _LcNrD') +parser.add_argument("-id", "--input_delimiter", type=str, default='\\n', + help='this is the delimiter you want lcNrD to use for the input file') # store true or false so we can just be like 'if args.lowercase:' # so use true or false values instead of comparing strings @@ -41,6 +43,11 @@ help='add a -kae to add some text to the end of every line') args = parser.parse_args() +# check if input_delimiter is set to default & if so rectify escape character +# this escapse character is left in so that the default value displays correctly in -h +if(args.input_delimiter == "\\n"): + args.input_delimiter = "\n" + print('Grabbing file contents...') # open the target file & grab its contents. Using `with` like this automatically @@ -49,7 +56,7 @@ text = fp.read() # let's create an array of the lines -lines = text.split("\n") +lines = text.split(args.input_delimiter) # Remove blank lines if args.blank_lines: From 976b840a9729df6fdf65013fec60d0566635021f Mon Sep 17 00:00:00 2001 From: justjcurtis Date: Fri, 5 Jul 2019 12:15:51 +0100 Subject: [PATCH 2/3] added updates to Readme --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5eb87f5..d5a4eea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lcNrD v1.6 +# lcNrD v1.6.5 lowercase AND remove Duplicates - A Very Simple Program; @@ -8,6 +8,7 @@ I find myself having to clean up data quite often & lose python scripts that I w As it stands, this program works best with text listed using the '\n' delimiter. I plan to soon add more delimiter options ## Current Functionality: +* Set input delimiter * Lowercase the text of a file * Remove duplicates of a file * Copy all operations onto a new file @@ -25,6 +26,8 @@ As it stands, this program works best with text listed using the '\n' delimiter. treatment (default: None) -o OUT, --out OUT this is the file you want the lcNrD file to output as. Default = same name + _LcNrD (default: None) + -id INPUT_DELIMITER, --input_delimiter INPUT_DELIMITER + this is the delimiter you want lcNrD to use for the -l, --lowercase add -l to set lowercase to true (default: False) -d, --duplicates add -d to remove duplicate elements (default: False) -s, --shuffle add -s to shuffle your list (default: False) @@ -71,5 +74,4 @@ If you'd like to be able to access lcnrd from anywhere on your computer, add the 7. You should now from anywhere on your computer be able to type simply `lcnrd -h` from a terminal & it should work! ## Roadmap: -* Add input delimiter * Add output delimiter From a8b980058b25fcb3d2bb3ea8b75a9a486ab27b37 Mon Sep 17 00:00:00 2001 From: Jacson Curtis Date: Fri, 5 Jul 2019 12:24:02 +0100 Subject: [PATCH 3/3] Update README.md added missing text --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5a4eea..2c57b14 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ As it stands, this program works best with text listed using the '\n' delimiter. Default = same name + _LcNrD (default: None) -id INPUT_DELIMITER, --input_delimiter INPUT_DELIMITER this is the delimiter you want lcNrD to use for the - -l, --lowercase add -l to set lowercase to true (default: False) + input file (default: \n) -d, --duplicates add -d to remove duplicate elements (default: False) -s, --shuffle add -s to shuffle your list (default: False) -rf, --replace_file add -rf to replace the original file after lcnrd