Spaces:
Sleeping
Sleeping
Create export/journalist_zip.py
Browse files- export/journalist_zip.py +6 -2
export/journalist_zip.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
| 1 |
-
import zipfile
|
|
|
|
| 2 |
|
| 3 |
def export_zip(results):
|
| 4 |
buf = io.BytesIO()
|
| 5 |
with zipfile.ZipFile(buf, "w") as z:
|
| 6 |
for i, r in enumerate(results):
|
| 7 |
-
z.writestr(
|
|
|
|
|
|
|
|
|
|
| 8 |
buf.seek(0)
|
| 9 |
return buf
|
|
|
|
| 1 |
+
import zipfile
|
| 2 |
+
import io
|
| 3 |
|
| 4 |
def export_zip(results):
|
| 5 |
buf = io.BytesIO()
|
| 6 |
with zipfile.ZipFile(buf, "w") as z:
|
| 7 |
for i, r in enumerate(results):
|
| 8 |
+
z.writestr(
|
| 9 |
+
f"{i}_{r['agency']}.txt",
|
| 10 |
+
f"{r['title']}\n{r['url']}"
|
| 11 |
+
)
|
| 12 |
buf.seek(0)
|
| 13 |
return buf
|