From 8bfec64edce399a3e90db32d6b8b5b2877394f88 Mon Sep 17 00:00:00 2001 From: Jeremias Moreira Gomes Date: Fri, 7 Oct 2022 19:59:49 -0300 Subject: [PATCH 1/8] Fix typos in Caesar Cipher. --- README.md | 4 +-- caesar_cipher/README.md | 27 +++++++++++++++++++ .../caeser.py => caesar_cipher/caesar.py | 8 +++--- caeser_cipher/README.md | 27 ------------------- 4 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 caesar_cipher/README.md rename caeser_cipher/caeser.py => caesar_cipher/caesar.py (90%) delete mode 100644 caeser_cipher/README.md diff --git a/README.md b/README.md index 2027e1b..df14cfb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ So far, the following projects have been integrated to this repo: |[Bitcoin price GUI](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Bitcoin-Price-GUI) |[Amirul Abu](https://github.com/amirulabu) | |[Cryptocurrency Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Cryptocurrency-converter) |[AdnCodz](https://github.com/AdnCodez) | |[Cryptocurrency Prices](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Cryptocurrency-Prices) |[xemeds](https://github.com/xemeds) | -|[Caesar Cipher](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/caeser_cipher) |[epi052](https://github.com/epi052) | +|[Caesar Cipher](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/caesar_cipher) |[epi052](https://github.com/epi052) | |[Checksum tool](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Checksum) |[Austin Ewens](https://github.com/aewens) | |[Codechef autosubmitter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Codechef-Code-Submitter) |[Harshit Mahajan](https://github.com/hmahajan99) | |[Colored B&W Image Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Color_to_BW_Converter) |[Nitish Srivastava](https://github.com/nitish-iiitd) | @@ -100,7 +100,7 @@ So far, the following projects have been integrated to this repo: |[Asymmetric Encryption](asymmetric_cryptography) |[victor matheus](https://github.com/victormatheusc) | |[Bitcoin price GUI](Bitcoin-Price-GUI) |[Amirul Abu](https://github.com/amirulabu) | |[Cryptocurrency Converter](Cryptocurrency-converter) |[AdnCodz](https://github.com/AdnCodez) | -|[Caesar Cipher](caeser_cipher) |[epi052](https://github.com/epi052) | +|[Caesar Cipher](caesar_cipher) |[epi052](https://github.com/epi052) | |[Checksum tool](Checksum) |[Austin Ewens](https://github.com/aewens) | |[Codechef autosubmitter](Codechef-Code-Submitter) |[Harshit Mahajan](https://github.com/hmahajan99) | |[Colored B&W Image Converter](Color_to_BW_Converter) |[Nitish Srivastava](https://github.com/nitish-iiitd) | diff --git a/caesar_cipher/README.md b/caesar_cipher/README.md new file mode 100644 index 0000000..7a2debc --- /dev/null +++ b/caesar_cipher/README.md @@ -0,0 +1,27 @@ +# Simple caesar Cipher [En,De]coder + +A simple implementation of a CLI tool to work with caesar ciphers. The default implementation is ROT-13, but can be +adjusted for any offset. Works on files and string arguments passed via CLI. + +```bash +python3 caesar.py + +usage: caesar.py [-h] [-d] [-o OFFSET] (-f FILE | -s STRING) +caesar.py: error: one of the arguments -f/--file -s/--string is required +``` + +```bash +python3 caesar.py -s "have you tried turning it off and on again?" +unir lbh gevrq gheavat vg bss naq ba ntnva? +``` + +```bash +python3 caesar.py -d -s "unir lbh gevrq gheavat vg bss naq ba ntnva?" +have you tried turning it off and on again? +``` + +```bash +python3 caesar.py -s "have you tried turning it off and on again?" -o -4 +dwra ukq pneaz pqnjejc ep kbb wjz kj wcwej? +``` + diff --git a/caeser_cipher/caeser.py b/caesar_cipher/caesar.py similarity index 90% rename from caeser_cipher/caeser.py rename to caesar_cipher/caesar.py index 8f6a523..40047cf 100755 --- a/caeser_cipher/caeser.py +++ b/caesar_cipher/caesar.py @@ -9,8 +9,8 @@ except AttributeError: maketrans = str.maketrans # python3 -def caeser_cipher(string_: str, offset: int, decode: bool, file_: string) -> None: - """ Caeser Cipher implementation, reads file or string. Also decodes. +def caesar_cipher(string_: str, offset: int, decode: bool, file_: string) -> None: + """ caesar Cipher implementation, reads file or string. Also decodes. Default implementation is ROT13 encoding. @@ -59,7 +59,7 @@ def check_offset_range(value: int) -> int: if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Simple Caeser Cipher [En,De]coder") + parser = argparse.ArgumentParser(description="Simple caesar Cipher [En,De]coder") parser.add_argument('-d', '--decode', action='store_true', dest='decode', help='decode ciphertext (offset should equal what was used to encode)', default=False) @@ -72,4 +72,4 @@ if __name__ == '__main__': args = parser.parse_args() - caeser_cipher(args.string, args.offset, args.decode, args.file) + caesar_cipher(args.string, args.offset, args.decode, args.file) diff --git a/caeser_cipher/README.md b/caeser_cipher/README.md deleted file mode 100644 index 86fef4f..0000000 --- a/caeser_cipher/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Simple Caeser Cipher [En,De]coder - -A simple implementation of a CLI tool to work with caeser ciphers. The default implementation is ROT-13, but can be -adjusted for any offset. Works on files and string arguments passed via CLI. - -```bash -python3 caeser.py - -usage: caeser.py [-h] [-d] [-o OFFSET] (-f FILE | -s STRING) -caeser.py: error: one of the arguments -f/--file -s/--string is required -``` - -```bash -python3 caeser.py -s "have you tried turning it off and on again?" -unir lbh gevrq gheavat vg bss naq ba ntnva? -``` - -```bash -python3 caeser.py -d -s "unir lbh gevrq gheavat vg bss naq ba ntnva?" -have you tried turning it off and on again? -``` - -```bash -python3 caeser.py -s "have you tried turning it off and on again?" -o -4 -dwra ukq pneaz pqnjejc ep kbb wjz kj wcwej? -``` - From ec995a1081107f5ef4a4083106990bf6949cd3d5 Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:13:24 +0500 Subject: [PATCH 2/8] Added Files --- PdfToAudio/pdf_to_audiobook.py | 26 ++++++++++++++++++++++++++ PdfToAudio/requirements.txt.txt | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 PdfToAudio/pdf_to_audiobook.py create mode 100644 PdfToAudio/requirements.txt.txt diff --git a/PdfToAudio/pdf_to_audiobook.py b/PdfToAudio/pdf_to_audiobook.py new file mode 100644 index 0000000..4882909 --- /dev/null +++ b/PdfToAudio/pdf_to_audiobook.py @@ -0,0 +1,26 @@ +# Importing the required packages. +import PyPDF2 +import pyttsx3 + +text = None + +# Reading a PDF file from your computer by specifying the path and setting the read mode to binary. +pdf_reader = PyPDF2.PdfFileReader(open(r"D:\MyPdf.pdf", "rb")) + +# Getting the handle to speaker i.e. creating a reference to pyttsx3.Engine instance. +speaker = pyttsx3.init() + +# Splitting the PDF file into pages and reading one at a time. +for page_number in range(pdf_reader.numPages): + text = pdf_reader.getPage(page_number).extractText() + # Generating speech. + speaker.say(text) + speaker.runAndWait() + +# Stopping the speaker after the complete audio has been created. +speaker.stop() + +# Saving the audiobook to your computer. +engine = pyttsx3.init() +engine.save_to_file(text, r"D:\MyAudio.mp3") +engine.runAndWait() diff --git a/PdfToAudio/requirements.txt.txt b/PdfToAudio/requirements.txt.txt new file mode 100644 index 0000000..3b1e4ed --- /dev/null +++ b/PdfToAudio/requirements.txt.txt @@ -0,0 +1,2 @@ +PyPDF2 +pyttsx3 \ No newline at end of file From 1ca77567c79f01ea28b0f3c88da5589405f9efef Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:15:57 +0500 Subject: [PATCH 3/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2027e1b..f6b075b 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ So far, the following projects have been integrated to this repo: |[Pressure_Converter](https://github.com/E-wave112/Awesome-Python-Scripts/tree/master/Pressure_Converter)|[E-Wave](https://github.com/E-wave112)| | [File Carving](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File_Carving) | [Yeryeong Kim](https://github.com/icarusicarus/) | |[Google Meet Joiner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/google_meet_joiner)|[JohanSanSebastian](https://github.com/JohanSanSebastian)| +| [Pdf to AudioBook](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | ## How to use : From 790c2b578a04d3abadecde1a2de7b7f1b4f9ed04 Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Sat, 8 Oct 2022 16:16:49 +0500 Subject: [PATCH 4/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6b075b..34d49eb 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ So far, the following projects have been integrated to this repo: |[Pressure_Converter](https://github.com/E-wave112/Awesome-Python-Scripts/tree/master/Pressure_Converter)|[E-Wave](https://github.com/E-wave112)| | [File Carving](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File_Carving) | [Yeryeong Kim](https://github.com/icarusicarus/) | |[Google Meet Joiner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/google_meet_joiner)|[JohanSanSebastian](https://github.com/JohanSanSebastian)| -| [Pdf to AudioBook](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | +| [Pdf to AudioBook Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | ## How to use : From ad1cc40043c22e6ef5a5b84b7440ce152804703b Mon Sep 17 00:00:00 2001 From: Bhargav Kuvadiya Date: Sun, 9 Oct 2022 10:24:24 +0530 Subject: [PATCH 5/8] [+] Added : New Script To Manage CSV For Storage -> will allow the user to manage CSV files -> filter data based on certain conditions. -> update data at particular row in csv. --- Better_CSV_Storage/README.md | 42 +++++++++++ Better_CSV_Storage/better_csv_storage.py | 95 ++++++++++++++++++++++++ Better_CSV_Storage/dummy_data.csv | 7 ++ 3 files changed, 144 insertions(+) create mode 100644 Better_CSV_Storage/README.md create mode 100644 Better_CSV_Storage/better_csv_storage.py create mode 100644 Better_CSV_Storage/dummy_data.csv diff --git a/Better_CSV_Storage/README.md b/Better_CSV_Storage/README.md new file mode 100644 index 0000000..61debd5 --- /dev/null +++ b/Better_CSV_Storage/README.md @@ -0,0 +1,42 @@ +p + +# Better CSV Storage + +-> For User / Programmer who don't want to use databases and want to use csv instead, this script will help manage that csv file (storage) + + + +### What you Can Do ? + +-> Filter Data Based On Certain Conditions that you provide, + +-> Update Certain Value in particular row. + + + +### How to use ? + +-> It's OOP based Script so just import that in you Regular Script. + +-> For Example, + +​ -> I want to check and download_status of files. + +​ -> csv file i have used -> `dummy_data.csv` + +```python +csv_path = 'dummy_data.csv' + +#init class and get the object +csv_obj = BetterCSVStorage(csv_path) + +#Now user that object as storage + +#Filter Data Based on Different parameters +#This List will contain additional ( update_index ) which is row index of each row in csv. +#This update_index will be use to update value of certain index. +filtered_data = csv_obj.get_filtered_data('download_status', '==', '') + +#Change Data Based on Different parameters +csv_obj.update_data(10,'download_status', 'done') +``` diff --git a/Better_CSV_Storage/better_csv_storage.py b/Better_CSV_Storage/better_csv_storage.py new file mode 100644 index 0000000..01af026 --- /dev/null +++ b/Better_CSV_Storage/better_csv_storage.py @@ -0,0 +1,95 @@ +import csv + +class BetterCSVStorage(): + + def __init__(self, csv_path): + self.csv_f_path = csv_path + self.valid_headers = None + self.allowed_comparison = ['==', '!='] + + def load(self): + with open(self.csv_f_path, 'r') as csv_f: + csv_reader = csv.reader(csv_f) + self.valid_headers = next(csv_reader) + + def write_dict_csv(self, data_rows): + if data_rows: + field_names = list(data_rows[0].keys()) + with open(self.csv_f_path,'w') as csv_wf: + csv_writer = csv.DictWriter(csv_wf, fieldnames=field_names) + csv_writer.writeheader() + for row in data_rows: + csv_writer.writerow(row) + print('[+] Data Written Successfully ...') + else: + print('[-] Error : Data Rows Could not be empty ...') + + def get_filtered_data(self, col_name, comparison, value): + if not self.valid_headers: + self.load() + if not col_name in self.valid_headers: + print('[-] Error : Enter Valid Column Name.') + print('[*] Info : Allowed Column Names Are : {}'.format(', '.join(self.valid_headers))) + else: + if not comparison in self.allowed_comparison: + print('[-] Error : Invalid Comparison.') + print('[*] Info : Allowed Comparison Are : {}'.format(', '.join(self.allowed_comparison))) + else: + filtered_data = [] + with open(self.csv_f_path,'r') as c_file: + csv_reader = csv.DictReader(c_file) + for row_index, row in enumerate(csv_reader): + try: + if (comparison == '=='): + if row[col_name] == value: + row['update_index'] = row_index + filtered_data.append(row) + if (comparison == '!='): + if row[col_name] != value: + row['update_index'] = row_index + filtered_data.append(row) + except KeyError: + continue + return filtered_data + + def update_data(self, update_index, col_name, value): + if not self.valid_headers: + self.load() + if not col_name in self.valid_headers: + print('[-] Error : Enter Valid Column Name.') + print('[*] Info : Allowed Column Names Are : {}'.format(', '.join(self.valid_headers))) + else: + if not update_index: + print('[-] Error Valid Data Index ....') + else: + try: + update_index = int(update_index) + except: + print('[-] Error : Update Index is Not Valid') + return + updated_rows = [] + with open(self.csv_f_path,'r') as csv_rf: + csv_reader = csv.DictReader(csv_rf) + for row_index, row in enumerate(csv_reader): + if update_index == row_index: + print('[+] Updating Index {}'.format(update_index)) + row[col_name] = value + updated_rows.append(row) + self.write_dict_csv(updated_rows) + +if __name__ == '__main__': + + csv_path = 'dummy_data.csv' + + #init class and get the object + csv_obj = BetterCSVStorage(csv_path) + + #Now user that object as storage + + #Filter Data Based on Different parameters + #This List will contain additional ( update_index ) which is row index of each row in csv. + #This update_index will be use to update value of certain index. + filtered_data = csv_obj.get_filtered_data('download_status', '==', '') + + #Change Data Based on Different parameters + csv_obj.update_data(4,'download_status', 'done') diff --git a/Better_CSV_Storage/dummy_data.csv b/Better_CSV_Storage/dummy_data.csv new file mode 100644 index 0000000..caaadff --- /dev/null +++ b/Better_CSV_Storage/dummy_data.csv @@ -0,0 +1,7 @@ +id,file_name,file_url,download_date,download_status +1430,sample_video1.mp4,https://example.com/download/sample_video1.mp4,05/10/22, +239,sample_video2.mp4,https://example.com/download/sample_video2.mp4,05/10/22, +3421,sample_video3.mp4,https://example.com/download/sample_video3.mp4,05/10/22, +1305,sample_video4.mp4,https://example.com/download/sample_video4.mp4,05/10/22, +6375,sample_video5.mp4,https://example.com/download/sample_video5.mp4,06/10/22,done +1203,sample_video6.mp4,https://example.com/download/sample_video6.mp4,06/10/22,done From ef22f476100874c8b1746c75b5cd8843d70268de Mon Sep 17 00:00:00 2001 From: Bhargav Kuvadiya Date: Sun, 9 Oct 2022 10:26:16 +0530 Subject: [PATCH 6/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2027e1b..fbca195 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ So far, the following projects have been integrated to this repo: |[AI chatbot](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Artificial-intelligence_bot) |[umar abdullahi](https://github.com/umarbrowser) | |[Asymmetric Encryption](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/asymmetric_cryptography) |[victor matheus](https://github.com/victormatheusc) | |[Bitcoin price GUI](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Bitcoin-Price-GUI) |[Amirul Abu](https://github.com/amirulabu) | +|[Better_CSV_Storage](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Better_CSV_Storage) | [Bhargav Kuvadiya](https://github.com/techdobz) | |[Cryptocurrency Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Cryptocurrency-converter) |[AdnCodz](https://github.com/AdnCodez) | |[Cryptocurrency Prices](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Cryptocurrency-Prices) |[xemeds](https://github.com/xemeds) | |[Caesar Cipher](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/caeser_cipher) |[epi052](https://github.com/epi052) | From a1637a18200e105c063d548084be641531e330e0 Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:52:09 +0500 Subject: [PATCH 7/8] Added Files --- PdfToAudio/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 PdfToAudio/README.md diff --git a/PdfToAudio/README.md b/PdfToAudio/README.md new file mode 100644 index 0000000..ee32722 --- /dev/null +++ b/PdfToAudio/README.md @@ -0,0 +1,6 @@ +# Pdf to Audiobook Converter +This python script generates audio for given pdf files. + +## Dependencies / Requirements +- PyPDF2. Install it by typing this command in your terminal `pip install PyPDF2` +- pyttsx3. Install it by `pip install pyttsx3` From 03ef44b67cb3fd94693267f7e7eed45eb06f872e Mon Sep 17 00:00:00 2001 From: Ayesha <106478752+ayeshag7@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:53:50 +0500 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34d49eb..5d46c54 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ So far, the following projects have been integrated to this repo: |[Pressure_Converter](https://github.com/E-wave112/Awesome-Python-Scripts/tree/master/Pressure_Converter)|[E-Wave](https://github.com/E-wave112)| | [File Carving](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/File_Carving) | [Yeryeong Kim](https://github.com/icarusicarus/) | |[Google Meet Joiner](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/google_meet_joiner)|[JohanSanSebastian](https://github.com/JohanSanSebastian)| -| [Pdf to AudioBook Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio) | [Ayesha Gull](https://github.com/ayeshag7/) | +|[Pdf to AudioBook Converter](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/PdfToAudio)|[Ayesha Gull](https://github.com/ayeshag7/)| ## How to use :