Merge branch 'main' of https://github.com/666ghj/Weibo_PublicOpinion_AnalysisSystem
Showing
2 changed files
with
4 additions
and
5 deletions
spider/article.csv
deleted
100644 → 0
| 1 | -id,likeNum,commentsLen,reposts_count,region,content,contentLen,created_at,type,detailUrl,authorAvatar,authorName,authorDetail,isVip |
| @@ -20,13 +20,13 @@ def save_to_sql(): | @@ -20,13 +20,13 @@ def save_to_sql(): | ||
| 20 | concatArticlePd.to_sql('article', con=engine, if_exists='replace', index=False) | 20 | concatArticlePd.to_sql('article', con=engine, if_exists='replace', index=False) |
| 21 | concatCommentsPd.to_sql('comments', con=engine, if_exists='replace', index=False) | 21 | concatCommentsPd.to_sql('comments', con=engine, if_exists='replace', index=False) |
| 22 | except: | 22 | except: |
| 23 | - articleNewPd = pd.read_csv('articleData.csv') | ||
| 24 | - commentNewPd = pd.read_csv('articleComments.csv') | 23 | + articleNewPd = pd.read_csv('article.csv') |
| 24 | + commentNewPd = pd.read_csv('comments.csv') | ||
| 25 | articleNewPd.to_sql('article',con=engine,if_exists='replace',index=False) | 25 | articleNewPd.to_sql('article',con=engine,if_exists='replace',index=False) |
| 26 | commentNewPd.to_sql('comments',con=engine,if_exists='replace',index=False) | 26 | commentNewPd.to_sql('comments',con=engine,if_exists='replace',index=False) |
| 27 | 27 | ||
| 28 | - os.remove('./articleData.csv') | ||
| 29 | - os.remove('./articleComments.csv') | 28 | + os.remove('./article.csv') |
| 29 | + os.remove('./comments.csv') | ||
| 30 | 30 | ||
| 31 | if __name__ == '__main__': | 31 | if __name__ == '__main__': |
| 32 | save_to_sql() | 32 | save_to_sql() |
-
Please register or login to post a comment