Skip to content

Instantly share code, notes, and snippets.

@wittyfilter

wittyfilter/zoey1.py

Created Dec 20, 2019
Embed
What would you like to do?
import pinyin
import csv
from itertools import islice
mydict = {}
with open('code.csv', newline='', encoding='utf-8-sig')as f1:
rows = csv.reader(f1, delimiter=',')
for row in rows:
key = row[0]
mydict[key] = row[1]
file = open('output.txt','w',encoding="utf-8")
with open('namelist.csv', newline='', encoding='utf-8')as f2:
f_csv = csv.reader(f2, delimiter=',')
for row in islice(f_csv, 1, None):
out = 'insert into auth_user(remarks, name, position, mobile, user_name, password, role_codes, region_codes, is_encrypt, created_at) values(\'' + row[1].strip() + '\',\'' + row[2].strip() + '\',\'' + row[3].strip() + '\',\'' + row[4].strip() + '\',\'' + pinyin.get(row[2].strip(), format="strip", delimiter="") + '\',\'NULL\', \'MUI,IQC\', \'-1,0'+ mydict[row[1].strip()] +'\', 0, now());\n'
file.write(out)
file.close()
f1.close()
f2.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.