imp_selected.py 347 B

12345678910111213141516
  1. import dataset
  2. import codecs
  3. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  4. table=db['selected_kw']
  5. fr=codecs.open('C:\\tmp\\selected.csv','r','utf-8')
  6. lines=fr.readlines()
  7. lst=[]
  8. for l in lines:
  9. term=l.replace('\n','')
  10. term=term.replace('\r','')
  11. table.insert({'term':term,'client':'清原'})