nijoow commited on
Commit
936adb9
Β·
1 Parent(s): 50ce5a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -27,14 +27,8 @@ def get_pdf_text(pdf_docs):
27
  # 과제
28
  # μ•„λž˜ ν…μŠ€νŠΈ μΆ”μΆœ ν•¨μˆ˜λ₯Ό μž‘μ„±
29
  def get_text_file(docs):
30
- with NamedTemporaryFile() as temp_file:
31
- temp_file.write(docs.getvalue())
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
- return csv_data
 
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
- return json_data
 
 
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
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.