Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -28,14 +28,8 @@ def get_pdf_text(pdf_docs):
|
|
28 |
# ๊ณผ์
|
29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
30 |
def get_text_file(docs):
|
31 |
-
|
32 |
-
|
33 |
-
temp_file.seek(0)
|
34 |
-
|
35 |
-
# ํ
์คํธ ํ์ผ์์ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ๋ก์ง์ ๊ตฌํํฉ๋๋ค.
|
36 |
-
text_content = temp_file.read().decode('utf-8')
|
37 |
-
|
38 |
-
return text_content
|
39 |
|
40 |
|
41 |
import csv
|
@@ -43,23 +37,25 @@ import json
|
|
43 |
from tempfile import NamedTemporaryFile
|
44 |
|
45 |
def get_csv_file(docs):
|
46 |
-
with NamedTemporaryFile() as temp_file:
|
47 |
-
temp_file.write(docs.getvalue())
|
48 |
temp_file.seek(0)
|
49 |
|
50 |
csv_data = []
|
51 |
csv_reader = csv.reader(temp_file)
|
52 |
for row in csv_reader:
|
53 |
csv_data.append(row)
|
54 |
-
|
|
|
55 |
|
56 |
def get_json_file(docs):
|
57 |
-
with NamedTemporaryFile() as temp_file:
|
58 |
-
temp_file.write(docs.getvalue())
|
59 |
temp_file.seek(0)
|
60 |
|
61 |
json_data = json.load(temp_file)
|
62 |
-
|
|
|
63 |
|
64 |
|
65 |
|
|
|
28 |
# ๊ณผ์
|
29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
30 |
def get_text_file(docs):
|
31 |
+
text_content = docs.getvalue().decode('utf-8')
|
32 |
+
return text_content
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
35 |
import csv
|
|
|
37 |
from tempfile import NamedTemporaryFile
|
38 |
|
39 |
def get_csv_file(docs):
|
40 |
+
with NamedTemporaryFile(delete=False) as temp_file:
|
41 |
+
temp_file.write(docs.getvalue().encode('utf-8'))
|
42 |
temp_file.seek(0)
|
43 |
|
44 |
csv_data = []
|
45 |
csv_reader = csv.reader(temp_file)
|
46 |
for row in csv_reader:
|
47 |
csv_data.append(row)
|
48 |
+
|
49 |
+
return csv_data
|
50 |
|
51 |
def get_json_file(docs):
|
52 |
+
with NamedTemporaryFile(delete=False) as temp_file:
|
53 |
+
temp_file.write(docs.getvalue().encode('utf-8'))
|
54 |
temp_file.seek(0)
|
55 |
|
56 |
json_data = json.load(temp_file)
|
57 |
+
|
58 |
+
return json_data
|
59 |
|
60 |
|
61 |
|