sujeongim0402@gmail.com commited on
Commit
30fbdf8
β€’
1 Parent(s): 8d79d7e

edit codes

Browse files
Files changed (1) hide show
  1. app.py +6 -20
app.py CHANGED
@@ -1,5 +1,3 @@
1
- import csv
2
- import json
3
  import streamlit as st
4
  from dotenv import load_dotenv
5
  from PyPDF2 import PdfReader
@@ -30,29 +28,17 @@ def get_pdf_text(pdf_docs):
30
  # 과제
31
  # μ•„λž˜ ν…μŠ€νŠΈ μΆ”μΆœ ν•¨μˆ˜λ₯Ό μž‘μ„±
32
 
33
- # Text file extraction
34
  def get_text_file(docs):
35
- return docs.read() # Assuming the input is already a text file
 
 
 
36
 
37
-
38
- # CSV file extraction
39
  def get_csv_file(docs):
40
- temp_dir = tempfile.TemporaryDirectory()
41
- temp_filepath = os.path.join(temp_dir.name, "temp.csv")
42
- with open(temp_filepath, "wb") as f:
43
- f.write(docs.getvalue())
44
-
45
- with open(temp_filepath, "r") as csv_file:
46
- csv_reader = csv.reader(csv_file)
47
- csv_data = [row for row in csv_reader]
48
-
49
- return csv_data
50
-
51
 
52
- # JSON file extraction
53
  def get_json_file(docs):
54
- json_data = json.loads(docs.read())
55
- return json_data
56
 
57
 
58
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
 
 
1
  import streamlit as st
2
  from dotenv import load_dotenv
3
  from PyPDF2 import PdfReader
 
28
  # 과제
29
  # μ•„λž˜ ν…μŠ€νŠΈ μΆ”μΆœ ν•¨μˆ˜λ₯Ό μž‘μ„±
30
 
 
31
  def get_text_file(docs):
32
+ file_path = 'study_plan.txt' # Replace with your file path
33
+ with open(file_path, 'r') as text_file:
34
+ result = get_text_file(text_file)
35
+ print(result)
36
 
 
 
37
  def get_csv_file(docs):
38
+ pass
 
 
 
 
 
 
 
 
 
 
39
 
 
40
  def get_json_file(docs):
41
+ pass
 
42
 
43
 
44
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.