Update app.py
#5
by MyeongGyun - opened
app.py
CHANGED
|
@@ -29,14 +29,22 @@ def get_pdf_text(pdf_docs):
|
|
| 29 |
# 아래 텍스트 추출 함수를 작성
|
| 30 |
|
| 31 |
def get_text_file(docs):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
def get_csv_file(docs):
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def get_json_file(docs):
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|
|
|
|
| 29 |
# 아래 텍스트 추출 함수를 작성
|
| 30 |
|
| 31 |
def get_text_file(docs):
|
| 32 |
+
return docs.read()
|
|
|
|
| 33 |
|
| 34 |
def get_csv_file(docs):
|
| 35 |
+
text = ''
|
| 36 |
+
if docs.name.endswith('.csv'):
|
| 37 |
+
reader = csv.reader(docs)
|
| 38 |
+
for row in reader:
|
| 39 |
+
text += ', '.join(row) + '\n'
|
| 40 |
+
return text
|
| 41 |
|
| 42 |
def get_json_file(docs):
|
| 43 |
+
text = ''
|
| 44 |
+
if docs.name.endswith('.json'):
|
| 45 |
+
data = json.load(docs)
|
| 46 |
+
text = json.dumps(data, indent=4)
|
| 47 |
+
return text
|
| 48 |
|
| 49 |
|
| 50 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|