DDingcheol commited on
Commit
08db112
Β·
1 Parent(s): e8eb4f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -25,7 +25,22 @@ def get_pdf_text(pdf_docs):
25
  # 과제
26
  # μ•„λž˜ ν…μŠ€νŠΈ μΆ”μΆœ ν•¨μˆ˜λ₯Ό μž‘μ„±
27
  def get_text_file(docs):
28
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  def get_csv_file(docs):
31
  pass
 
25
  # 과제
26
  # μ•„λž˜ ν…μŠ€νŠΈ μΆ”μΆœ ν•¨μˆ˜λ₯Ό μž‘μ„±
27
  def get_text_file(docs):
28
+ # .txt 파일의 λ‚΄μš©μ„ 담을 λ³€μˆ˜
29
+ txt_content = ""
30
+
31
+ # μž„μ‹œ 디렉토리 생성
32
+ temp_dir = tempfile.TemporaryDirectory()
33
+ temp_filepath = os.path.join(temp_dir.name, docs.name)
34
+
35
+ # .txt 파일의 λ‚΄μš©μ„ μž„μ‹œ νŒŒμΌμ— μ”λ‹ˆλ‹€.
36
+ with open(temp_filepath, "wb") as f:
37
+ f.write(docs.getvalue())
38
+
39
+ # .txt νŒŒμΌμ„ μ½μ–΄μ„œ λ‚΄μš©μ„ txt_content에 μ €μž₯ν•©λ‹ˆλ‹€.
40
+ with open(temp_filepath, "r", encoding="utf-8") as f:
41
+ txt_content = f.read()
42
+
43
+ return txt_content
44
 
45
  def get_csv_file(docs):
46
  pass