Spaces:
Sleeping
Sleeping
Delete pages/1_Executives.py
Browse files- pages/1_Executives.py +0 -138
pages/1_Executives.py
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python3
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
"""
|
4 |
-
Created on Tue Dec 26 21:08:06 2023
|
5 |
-
|
6 |
-
@author: mohanadafiffy
|
7 |
-
"""
|
8 |
-
|
9 |
-
import streamlit as st
|
10 |
-
import pandas as pd
|
11 |
-
import requests
|
12 |
-
import os
|
13 |
-
|
14 |
-
def main():
|
15 |
-
BackendService =os.getenv("backend_user")
|
16 |
-
input_data = None
|
17 |
-
submitted = None
|
18 |
-
|
19 |
-
# Wrap everything inside a form
|
20 |
-
with st.sidebar:
|
21 |
-
uploaded_file = st.file_uploader("Kindly upload a CSV file that includes the companies and LinkedIn URLs of the users", type=["csv"])
|
22 |
-
opt_out_scraping = st.checkbox("Opt out of scraping")
|
23 |
-
|
24 |
-
if uploaded_file is not None:
|
25 |
-
try:
|
26 |
-
# Detect file type and read accordingly
|
27 |
-
file_type = uploaded_file.name.split('.')[-1]
|
28 |
-
if file_type == 'csv':
|
29 |
-
try:
|
30 |
-
df = pd.read_csv(uploaded_file)
|
31 |
-
except:
|
32 |
-
df = pd.read_csv(uploaded_file, encoding='ISO-8859-1')
|
33 |
-
# Check if 'Person Linkedin Url' column exists
|
34 |
-
required_columns = ['First Name', 'Last Name', 'Title', 'Website','Company','Person Linkedin Url']
|
35 |
-
missing_columns = [col for col in required_columns if col not in df.columns]
|
36 |
-
|
37 |
-
for col in missing_columns:
|
38 |
-
all_columns = df.columns.tolist()
|
39 |
-
selected_column = st.selectbox(f"Select the column for {col}:", all_columns)
|
40 |
-
df.rename(columns={selected_column: col}, inplace=True)
|
41 |
-
if opt_out_scraping:
|
42 |
-
if 'User description' not in df.columns:
|
43 |
-
all_columns = df.columns.tolist()
|
44 |
-
description_column = st.selectbox("Select the column for Description:", all_columns)
|
45 |
-
df.rename(columns={description_column: 'Scrapped Profile'}, inplace=True)
|
46 |
-
else:
|
47 |
-
df.rename(columns={'User description': 'Scrapped Profile'}, inplace=True)
|
48 |
-
|
49 |
-
input_data = df
|
50 |
-
|
51 |
-
except Exception as E:
|
52 |
-
st.write(E)
|
53 |
-
st.error("An error occurred while processing the file")
|
54 |
-
|
55 |
-
with st.form(key='my_form'):
|
56 |
-
|
57 |
-
# List of predefined email addresses
|
58 |
-
email_options = [
|
59 |
-
"[email protected]",
|
60 |
-
"[email protected]",
|
61 |
-
"[email protected]",
|
62 |
-
"[email protected]",
|
63 |
-
"[email protected]",
|
64 |
-
"[email protected]",
|
65 | |
66 |
-
|
67 |
-
]
|
68 |
-
|
69 |
-
# Streamlit select box for choosing an email
|
70 |
-
email_receiver = st.selectbox("Please select an email address", email_options)
|
71 |
-
|
72 |
-
# If the button is clicked, it will return True for this run
|
73 |
-
button_clicked = st.form_submit_button("Submit")
|
74 |
-
|
75 |
-
# Update session state for the button
|
76 |
-
if button_clicked:
|
77 |
-
submitted = True
|
78 |
-
|
79 |
-
# Use the session state variable to determine if the button was previously clicked
|
80 |
-
if submitted and input_data is not None:
|
81 |
-
df = input_data
|
82 |
-
df = df.drop_duplicates(subset="Person Linkedin Url", keep='first')
|
83 |
-
df = df.dropna().loc[~(df == '').all(axis=1)]
|
84 |
-
if opt_out_scraping:
|
85 |
-
df=df[['First Name', 'Last Name', 'Title', 'Website','Company','Person Linkedin Url','Scrapped Profile']]
|
86 |
-
else:
|
87 |
-
df=df[['First Name', 'Last Name', 'Title', 'Website','Company','Person Linkedin Url']]
|
88 |
-
|
89 |
-
# Convert DataFrame to CSV for transmission
|
90 |
-
csv = df.to_csv(index=False)
|
91 |
-
|
92 |
-
# Construct the data to send
|
93 |
-
data_to_send = {"dataframe": csv, "email_receiver": email_receiver}
|
94 |
-
|
95 |
-
# Sending the POST request to FastAPI
|
96 |
-
response = requests.post(BackendService, json=data_to_send)
|
97 |
-
|
98 |
-
if response.status_code == 200:
|
99 |
-
st.info(f"We're processing your request. You can close the app now. An email will be sent to {email_receiver} once the process is finished.")
|
100 |
-
else:
|
101 |
-
st.error("Data transmission failed. Please verify that your file contains the labels 'Company' and 'Person Linkedin Url'. Additionally, ensure that your file is valid and contains records and try again, if the problem persists please contact us at [email protected]")
|
102 |
-
|
103 |
-
if __name__ == "__main__":
|
104 |
-
st.markdown(
|
105 |
-
"""
|
106 |
-
<style>
|
107 |
-
.higher-title {
|
108 |
-
font-size:35px !important;
|
109 |
-
color: #4A90E2; /* Shade of blue */
|
110 |
-
text-align: center;
|
111 |
-
font-weight: bold;
|
112 |
-
margin-top: -20px; /* Adjust this value to control the height */
|
113 |
-
}
|
114 |
-
</style>
|
115 |
-
""",
|
116 |
-
unsafe_allow_html=True,
|
117 |
-
)
|
118 |
-
|
119 |
-
st.markdown('<p class="higher-title">SalesIntel AI</p>', unsafe_allow_html=True)
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
logo_url = "https://i.imgur.com/WYnv26e.jpeg" # Replace this with your image's direct URL
|
124 |
-
st.markdown(
|
125 |
-
f"""
|
126 |
-
<style>
|
127 |
-
.logo {{
|
128 |
-
position: fixed;
|
129 |
-
bottom: 5px;
|
130 |
-
right: 5px;
|
131 |
-
width: 100px; # Adjust width as needed
|
132 |
-
}}
|
133 |
-
</style>
|
134 |
-
<img src="{logo_url}" class="logo">
|
135 |
-
""",
|
136 |
-
unsafe_allow_html=True,
|
137 |
-
)
|
138 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|