Last active
August 29, 2015 14:13
-
-
Save lazybios/ef7c757be22bc6dd6d1f 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
#!/usr/bin/python | |
# coding: utf-8 | |
import csv | |
import json | |
import sys | |
if __name__ == "__main__": | |
# execel 导出后带有^M符号 换行符号 'rU' U通用换行符 | |
with open(sys.argv[1],'rU') as fd: | |
line = csv.reader(fd,delimiter=',') | |
collection = dict() | |
for x in line: | |
data = dict() | |
profile = dict() | |
data['home_subway'] = x[9] | |
data['company_subway'] = x[10] | |
profile['gender'] = x[2] | |
profile['hometown'] = x[13] | |
profile['edu_year'] = x[3] | |
profile['edu_department'] = x[4] | |
profile['edu_major'] = x[5] | |
profile['job_company'] = x[6] | |
profile['job_position'] = x[8] | |
profile['qq'] = x[12] | |
profile['phone'] = x[11] | |
data['profile'] = profile | |
name_key = str(x[0]+'-'+x[1]) | |
collection[name_key] = data | |
#要输出中文需要指定ensure_ascii参数为False | |
print json.dumps(collection,ensure_ascii=False,indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment