Created
December 20, 2019 02:25
-
-
Save wittyfilter/6c35d8285c73be7895e378523df9ec89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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