Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,14 +41,19 @@ def get_text_file(docs):
|
|
41 |
return text_doc # μΆμΆν ν
μ€νΈλ₯Ό λ°νν©λλ€.
|
42 |
|
43 |
|
44 |
-
def
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
|
54 |
def get_json_file(docs):
|
|
|
41 |
return text_doc # μΆμΆν ν
μ€νΈλ₯Ό λ°νν©λλ€.
|
42 |
|
43 |
|
44 |
+
def get_csv_text(csv_file):
|
45 |
+
# μμ νμΌμ μμ±νκ³ , μ
λ‘λλ CSV νμΌμ λ΄μ©μ μλλ€.
|
46 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as temp_file:
|
47 |
+
temp_file.write(csv_file.read())
|
48 |
+
temp_file_path = temp_file.name # μμ νμΌ κ²½λ‘λ₯Ό μ μ₯ν©λλ€.
|
49 |
+
|
50 |
+
# CSV νμΌμ μ΄κ³ λ΄μ©μ μ½μ΅λλ€.
|
51 |
+
with open(temp_file_path, mode='r', encoding='utf-8') as file:
|
52 |
+
csv_reader = csv.reader(file)
|
53 |
+
csv_text = "\n".join([", ".join(row) for row in csv_reader]) # κ° νμ λ¬Έμμ΄λ‘ λ³νν©λλ€.
|
54 |
+
|
55 |
+
os.remove(temp_file_path) # μμ νμΌμ μμ ν©λλ€.
|
56 |
+
return csv_text # CSV νμΌμ ν
μ€νΈλ₯Ό λ°νν©λλ€.
|
57 |
|
58 |
|
59 |
def get_json_file(docs):
|