Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions twitter_data_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ def _save_to_excel(json_filename, output_filename="data/data.xlsx"):

# Drop duplicates & save to Excel
cur_df.drop_duplicates(subset=["url"], inplace=True)
# 定义非法字符的正则表达式
ILLEGAL_CHARACTERS_RE = re.compile(r'[\000-\010]|[\013-\014]|[\016-\037]')
# 使用正则表达式替换非法字符
cur_df = cur_df.replace(ILLEGAL_CHARACTERS_RE, '', regex=True)
cur_df.to_excel(output_filename, index=False)
logger.info(
f"\n\nDone saving to {output_filename}. Total of {len(cur_df)} unique tweets."
Expand Down