Spaces:
Build error
Build error
TypeError fixes; save uploaded file-like obkect as temporary file for read_epub to handle
Browse files- src/file_readers.py +7 -1
src/file_readers.py
CHANGED
@@ -189,10 +189,16 @@ def read_epub(file):
|
|
189 |
title of document, used to name output files
|
190 |
|
191 |
"""
|
|
|
|
|
192 |
import ebooklib
|
193 |
from ebooklib import epub
|
|
|
194 |
|
195 |
-
|
|
|
|
|
|
|
196 |
file_title = book.get_metadata('DC', 'title')[0][0]
|
197 |
file_title = file_title.lower().replace(' ', '_')
|
198 |
corpus = []
|
|
|
189 |
title of document, used to name output files
|
190 |
|
191 |
"""
|
192 |
+
from pathlib import Path
|
193 |
+
|
194 |
import ebooklib
|
195 |
from ebooklib import epub
|
196 |
+
from tempfile import NamedTemporaryFile
|
197 |
|
198 |
+
with NamedTemporaryFile(dir='.', suffix='.csv') as f:
|
199 |
+
f.write(file.getbuffer())
|
200 |
+
file = Path(f.name)
|
201 |
+
book = epub.read_epub(file)
|
202 |
file_title = book.get_metadata('DC', 'title')[0][0]
|
203 |
file_title = file_title.lower().replace(' ', '_')
|
204 |
corpus = []
|