123456789101112131415161718192021222324252627282930313233 |
- import pandas as pd
- import dataset
- import json
- import pymysql
- pymysql.install_as_MySQLdb()
- # df = pd.read_csv(r"C:\/Users\/s1301\/Documents\/關鍵字建議.csv",engine='python')
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- # table=db['seo_jobs']
- table=db['selected_kw']
- f = open("/Users/mac/Downloads/456.csv")
- df = pd.read_csv(f,header=None, names=['id','cust','plan','json','is_nda','term'])
- df=df.fillna('')
- for index,row in df.iterrows():
- print(row)
- parsed_data = json.loads(row['json'])
- id = row['id']
- cust = row['cust']
- plan = row['plan']
- kw = parsed_data['prefix']
- domain = parsed_data['domain']
- # table.insert({'cust':'','plan':'形象SEO','json':json})
- table.insert({'term':kw,'client':cust,'domain':domain})
- # table.insert({'term': row['kw'], 'client': client, 'url': row['url']})
- db.close()
- ####先從雲端下載csv 再用記事本打開另存一個csv#########
|