Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -199,29 +199,15 @@ class FileProcessor:
|
|
199 |
|
200 |
return dataset
|
201 |
|
202 |
-
def
|
203 |
-
"""
|
204 |
-
|
205 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
206 |
-
zip_ref.extractall(
|
207 |
-
for
|
208 |
-
|
209 |
-
|
210 |
-
|
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)
|