File size: 1,203 Bytes
4a2e94e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# app.py
import streamlit as st
import pdfplumber
import ats
import docx

st.set_page_config(page_title='CareerEnchanter', page_icon='🤖', layout='centered')

st.title("Enchant your Career")

uploaded_file = st.file_uploader("Choose a document file", type=["pdf", "txt", "csv", "docx"])
text = ''
if uploaded_file is not None:
    st.write("File uploaded successfully!")

    file_extension = uploaded_file.name.split(".")[-1]

    if file_extension == "pdf":
        with pdfplumber.open(uploaded_file) as pdf:
            pages = pdf.pages
            for page in pages:
                text = page.extract_text()

    elif file_extension == "txt":
        text = uploaded_file.getvalue().decode("utf-8")
    
    elif file_extension == "docx":
        docx_text = docx.Document(uploaded_file)
        full_text = []
        for para in docx_text.paragraphs:
            full_text.append(para.text)
        text = "\n".join(full_text)

st.text_area("Extracted From Document",value=text)
st.session_state['doc_text'] = text

col1, col2, col3 = st.columns([3, 3,3])
option = st.radio("I want to use: ", ("ATS"), horizontal=True)


if option == "ATS":
    ats.run_ats(st.session_state['doc_text'])