acecalisto3 commited on
Commit
f6bca8a
·
verified ·
1 Parent(s): 75b5552

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -22
app.py CHANGED
@@ -199,29 +199,15 @@ class FileProcessor:
199
 
200
  return dataset
201
 
202
- def _process_zip_file(self, zip_path: str, temp_dir: str) -> List[Dict]:
203
- """Process ZIP file contents"""
204
- results = []
205
  with zipfile.ZipFile(zip_path, 'r') as zip_ref:
206
- zip_ref.extractall(temp_dir)
207
- for root, _, files in os.walk(temp_dir):
208
- for filename in files:
209
- filepath = os.path.join(root, filename)
210
- if self.is_text_file(filepath):
211
- try:
212
- with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
213
- content = f.read()
214
- if content.strip():
215
- results.append({
216
- "source": "file",
217
- "filename": filename,
218
- "content": content,
219
- "timestamp": datetime.now().isoformat()
220
- })
221
- except Exception as e:
222
- logger.error(f"Error reading file {filename}: {str(e)}")
223
- return results
224
-
225
  def _process_single_file(self, file) -> List[Dict]:
226
  try:
227
  file_stat = os.stat(file.name)
 
199
 
200
  return dataset
201
 
202
+ def process_zip_file(zip_path):
203
+ """Extract and process files within a ZIP archive."""
204
+ extraction_directory = tempfile.mkdtemp()
205
  with zipfile.ZipFile(zip_path, 'r') as zip_ref:
206
+ zip_ref.extractall(extraction_directory)
207
+ for extracted_file in os.listdir(extraction_directory):
208
+ extracted_file_path = os.path.join(extraction_directory, extracted_file)
209
+ process_file(extracted_file_path)
210
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  def _process_single_file(self, file) -> List[Dict]:
212
  try:
213
  file_stat = os.stat(file.name)