nijoow commited on
Commit
53e1a80
ยท
1 Parent(s): 3865418

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -28,14 +28,8 @@ def get_pdf_text(pdf_docs):
28
  # ๊ณผ์ œ
29
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
30
  def get_text_file(docs):
31
- with NamedTemporaryFile() as temp_file:
32
- temp_file.write(docs.getvalue())
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
- return csv_data
 
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
- return json_data
 
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