Spaces:
Build error
Build error
Update 01_π _Home.py
Browse files- 01_π _Home.py +14 -0
01_π _Home.py
CHANGED
|
@@ -8,6 +8,7 @@ import pandas as pd
|
|
| 8 |
import numpy as np
|
| 9 |
import plotly_express as px
|
| 10 |
import plotly.graph_objects as go
|
|
|
|
| 11 |
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode
|
| 12 |
|
| 13 |
st.set_page_config(
|
|
@@ -17,6 +18,8 @@ st.set_page_config(
|
|
| 17 |
)
|
| 18 |
|
| 19 |
st.sidebar.header("Sentiment Analysis Score")
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@st.experimental_singleton(suppress_st_warning=True)
|
| 22 |
def load_models():
|
|
@@ -109,6 +112,17 @@ if refresh_stream or st.session_state.update_but:
|
|
| 109 |
df_users = pd.DataFrame(data=list(set([(user.id,user.username) for user in users.data])),columns=['author','username'])
|
| 110 |
|
| 111 |
df_tweets = process_tweets(df,df_users)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
st.session_state['tdf'] = df_tweets
|
| 114 |
|
|
|
|
| 8 |
import numpy as np
|
| 9 |
import plotly_express as px
|
| 10 |
import plotly.graph_objects as go
|
| 11 |
+
from datetime import datetime as dt
|
| 12 |
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode
|
| 13 |
|
| 14 |
st.set_page_config(
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
st.sidebar.header("Sentiment Analysis Score")
|
| 21 |
+
|
| 22 |
+
extract_time = dt.strftime(dt.today(),"%d_%B_%y_%H_%M")
|
| 23 |
|
| 24 |
@st.experimental_singleton(suppress_st_warning=True)
|
| 25 |
def load_models():
|
|
|
|
| 112 |
df_users = pd.DataFrame(data=list(set([(user.id,user.username) for user in users.data])),columns=['author','username'])
|
| 113 |
|
| 114 |
df_tweets = process_tweets(df,df_users)
|
| 115 |
+
|
| 116 |
+
# Get all tweets
|
| 117 |
+
tweet_list = df_tweets['tweet'].tolist()
|
| 118 |
+
|
| 119 |
+
# Open file and write to it
|
| 120 |
+
with open(f'output/tweets_{extract_time}.txt', 'w') as file:
|
| 121 |
+
for tweet in tweet_list:
|
| 122 |
+
file.write(tweet + '\n')
|
| 123 |
+
|
| 124 |
+
# Close the file
|
| 125 |
+
file.close()
|
| 126 |
|
| 127 |
st.session_state['tdf'] = df_tweets
|
| 128 |
|