import_category.py 379 B

12345678910111213
  1. import codecs
  2. import dataset
  3. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/google_poi?charset=utf8mb4')
  4. table=db['category']
  5. fr=codecs.open('category.csv','r','utf-8')
  6. lines=fr.readlines()
  7. for l in lines:
  8. newl=l.strip()
  9. # print(newl)
  10. elmts=newl.split(',')
  11. table.insert({'keyword':elmts[0],'num':elmts[1],'label':elmts[2]})
  12. #print(lines)
  13. fr.close()