pratikshahp commited on
Commit
8b5fe19
·
verified ·
1 Parent(s): 155d510

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +15 -0
utils.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import zipfile
2
+ import os
3
+
4
+ def extract_zip(zip_file, extract_to):
5
+ with zipfile.ZipFile(zip_file, 'r') as zip_ref:
6
+ zip_ref.extractall(extract_to)
7
+
8
+ def read_texts_from_folder(folder_path):
9
+ texts = []
10
+ for root, _, files in os.walk(folder_path):
11
+ for file in files:
12
+ if file.endswith(".txt"):
13
+ with open(os.path.join(root, file), 'r', encoding='utf-8') as f:
14
+ texts.append(f.read())
15
+ return texts