12345678910111213141516 |
- import csv
- import dataset
- # 開啟 CSV 檔案
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/microfilm?charset=utf8mb4')
- with open('fbReport.csv', newline='',encoding='UTF-8') as csvfile:
- # 讀取 CSV 檔案內容
- rows = csv.reader(csvfile)
- # 以迴圈輸出每一列
- for row in rows:
-
- db['fbPosts'].insert({'club':row[0],'clubLikes':row[1],'postLikes':row[2]
- ,'content':row[3],'date':row[4],'shares':row[5]})
- db.close()
|