Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,14 +27,8 @@ def get_pdf_text(pdf_docs):
|
|
27 |
# κ³Όμ
|
28 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
29 |
def get_text_file(docs):
|
30 |
-
|
31 |
-
|
32 |
-
temp_file.seek(0)
|
33 |
-
|
34 |
-
# ν
μ€νΈ νμΌμμ ν
μ€νΈλ₯Ό μΆμΆνλ λ‘μ§μ ꡬνν©λλ€.
|
35 |
-
text_content = temp_file.read().decode('utf-8')
|
36 |
-
|
37 |
-
return text_content
|
38 |
|
39 |
|
40 |
import csv
|
@@ -42,23 +36,26 @@ import json
|
|
42 |
from tempfile import NamedTemporaryFile
|
43 |
|
44 |
def get_csv_file(docs):
|
45 |
-
with NamedTemporaryFile() as temp_file:
|
46 |
-
temp_file.write(docs.getvalue())
|
47 |
temp_file.seek(0)
|
48 |
|
49 |
csv_data = []
|
50 |
csv_reader = csv.reader(temp_file)
|
51 |
for row in csv_reader:
|
52 |
csv_data.append(row)
|
53 |
-
|
|
|
54 |
|
55 |
def get_json_file(docs):
|
56 |
-
with NamedTemporaryFile() as temp_file:
|
57 |
-
temp_file.write(docs.getvalue())
|
58 |
temp_file.seek(0)
|
59 |
|
60 |
json_data = json.load(temp_file)
|
61 |
-
|
|
|
|
|
62 |
|
63 |
|
64 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
|
|
27 |
# κ³Όμ
|
28 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
29 |
def get_text_file(docs):
|
30 |
+
text_content = docs.getvalue().decode('utf-8')
|
31 |
+
return text_content
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
|
34 |
import csv
|
|
|
36 |
from tempfile import NamedTemporaryFile
|
37 |
|
38 |
def get_csv_file(docs):
|
39 |
+
with NamedTemporaryFile(delete=False) as temp_file:
|
40 |
+
temp_file.write(docs.getvalue().encode('utf-8'))
|
41 |
temp_file.seek(0)
|
42 |
|
43 |
csv_data = []
|
44 |
csv_reader = csv.reader(temp_file)
|
45 |
for row in csv_reader:
|
46 |
csv_data.append(row)
|
47 |
+
|
48 |
+
return csv_data
|
49 |
|
50 |
def get_json_file(docs):
|
51 |
+
with NamedTemporaryFile(delete=False) as temp_file:
|
52 |
+
temp_file.write(docs.getvalue().encode('utf-8'))
|
53 |
temp_file.seek(0)
|
54 |
|
55 |
json_data = json.load(temp_file)
|
56 |
+
|
57 |
+
return json_data
|
58 |
+
|
59 |
|
60 |
|
61 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|