Spaces:
Build error
Build error
Update 01_π _Home.py
Browse files- 01_π _Home.py +5 -7
01_π _Home.py
CHANGED
@@ -27,6 +27,7 @@ DATASET_REPO_URL = "https://huggingface.co/datasets/nickmuchi/fin_tweets"
|
|
27 |
|
28 |
DATA_FILENAME = "tweets_data.csv"
|
29 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
|
|
30 |
|
31 |
repo = Repository(
|
32 |
local_dir="tweets", clone_from=DATASET_REPO_URL
|
@@ -88,16 +89,13 @@ if refresh_stream or st.session_state.update_but:
|
|
88 |
|
89 |
df_tweets = process_tweets(df,df_users)
|
90 |
|
|
|
|
|
|
|
91 |
# Get all tweets
|
92 |
tweet_list = df_tweets['tweet'].tolist()
|
93 |
|
94 |
-
|
95 |
-
with open(f'output/tweets_{extract_time}.txt', 'w') as file:
|
96 |
-
for tweet in tweet_list:
|
97 |
-
file.write(tweet + '\n')
|
98 |
-
|
99 |
-
# Close the file
|
100 |
-
file.close()
|
101 |
|
102 |
st.session_state['tdf'] = df_tweets
|
103 |
|
|
|
27 |
|
28 |
DATA_FILENAME = "tweets_data.csv"
|
29 |
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
30 |
+
tweet_file = os.path.join("tweets", DATA_FILE)
|
31 |
|
32 |
repo = Repository(
|
33 |
local_dir="tweets", clone_from=DATASET_REPO_URL
|
|
|
89 |
|
90 |
df_tweets = process_tweets(df,df_users)
|
91 |
|
92 |
+
#appending the new dataframe to csv
|
93 |
+
df_tweets.to_csv(tweet_file, mode='a', header=False, index=False)
|
94 |
+
|
95 |
# Get all tweets
|
96 |
tweet_list = df_tweets['tweet'].tolist()
|
97 |
|
98 |
+
st.session_state['tlist'] = df_tweets
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
st.session_state['tdf'] = df_tweets
|
101 |
|