def wenjuanwang(filepath='.\\data', encoding='gbk'):
    '问卷网数据导入和编码\n    输入：\n    filepath:\n        列表，[0]为按文本数据路径，[1]为按序号文本，[2]为编码文件\n        文件夹路径，函数会自动在文件夹下搜寻相关数据\n    输出：\n    (data,code):\n        data为按序号的数据，题目都替换成了Q_n\n        code为数据编码，可利用函数to_code()导出为json格式或者Excel格式数据\n    '
    if isinstance(filepath, list):
        filename1 = filepath[0]
        filename2 = filepath[1]
        filename3 = filepath[2]
    elif os.path.isdir(filepath):
        filename1 = os.path.join(filepath, 'All_Data_Readable.csv')
        filename2 = os.path.join(filepath, 'All_Data_Original.csv')
        filename3 = os.path.join(filepath, 'code.csv')
    else:
        print('can not dection the filepath!')
    d1 = pd.read_csv(filename1, encoding=encoding)
    d1.drop([u'答题时长'], axis=1, inplace=True)
    d2 = pd.read_csv(filename2, encoding=encoding)
    d3 = pd.read_csv(filename3, encoding=encoding, header=None, na_filter=False)
    d3 = d3.as_matrix()
    code = {}
    for i in range(len(d3)):
        if d3[(i, 0)]:
            key = d3[(i, 0)]
            code[key] = {}
            code[key]['content'] = d3[(i, 1)]
            code[key]['qtype'] = d3[(i, 2)]
            code[key]['code'] = {}
            code[key]['qlist'] = []
        elif d3[(i, 2)]:
            tmp = d3[(i, 1)]
            if (code[key]['qtype'] in [u'多选题', u'排序题']):
                tmp = ((key + '_A') + ('%s' % tmp))
                code[key]['code'][tmp] = ('%s' % d3[(i, 2)])
                code[key]['qlist'].append(tmp)
            elif (code[key]['qtype'] in [u'单选题']):
                try:
                    tmp = int(tmp)
                except:
                    tmp = ('%s' % tmp)
                code[key]['code'][tmp] = ('%s' % d3[(i, 2)])
                code[key]['qlist'] = [key]
            elif (code[key]['qtype'] in [u'填空题']):
                code[key]['qlist'] = [key]
            else:
                try:
                    tmp = int(tmp)
                except:
                    tmp = ('%s' % tmp)
                code[key]['code'][tmp] = ('%s' % d3[(i, 2)])
    qnames_Readable = list(d1.columns)
    qnames = list(d2.columns)
    for key in code.keys():
        qlist = []
        for name in qnames:
            if (re.match((key + '_'), name) or (key == name)):
                qlist.append(name)
        if (('qlist' not in code[key]) or (not code[key]['qlist'])):
            code[key]['qlist'] = qlist
        if (code[key]['qtype'] in [u'矩阵单选题']):
            tmp = [qnames_Readable[qnames.index(q)] for q in code[key]['qlist']]
            code_r = [re.findall('_([^_]*?)$', t)[0] for t in tmp]
            code[key]['code_r'] = dict(zip(code[key]['qlist'], code_r))
    d2['start'] = pd.to_datetime(d2['start'])
    d2['finish'] = pd.to_datetime(d2['finish'])
    tmp = (d2['finish'] - d2['start'])
    tmp = tmp.astype(str).map((lambda x: ((60 * int(re.findall(':(\\d+):', x)[0])) + int(re.findall(':(\\d+)\\.', x)[0]))))
    ind = np.where((d2.columns == 'finish'))[0][0]
    d2.insert((int(ind) + 1), u'答题时长(秒)', tmp)
    return (d2, code)
问卷网数据导入和编码
输入：
filepath:
    列表，[0]为按文本数据路径，[1]为按序号文本，[2]为编码文件
    文件夹路径，函数会自动在文件夹下搜寻相关数据
输出：
(data,code):
    data为按序号的数据，题目都替换成了Q_n
    code为数据编码，可利用函数to_code()导出为json格式或者Excel格式数据
def wenjuanwang(filepath='.\\data', encoding='gbk'):
    '问卷网数据导入和编码\n    输入：\n    filepath:\n        列表，[0]为按文本数据路径，[1]为按序号文本，[2]为编码文件\n        文件夹路径，函数会自动在文件夹下搜寻相关数据\n    输出：\n    (data,code):\n        data为按序号的数据，题目都替换成了Q_n\n        code为数据编码，可利用函数to_code()导出为json格式或者Excel格式数据\n    '
    if isinstance(filepath, list):
        filename1 = filepath[0]
        filename2 = filepath[1]
        filename3 = filepath[2]
    elif os.path.isdir(filepath):
        filename1 = os.path.join(filepath, 'All_Data_Readable.csv')
        filename2 = os.path.join(filepath, 'All_Data_Original.csv')
        filename3 = os.path.join(filepath, 'code.csv')
    else:
        print('can not dection the filepath!')
    d1 = pd.read_csv(filename1, encoding=encoding)
    d1.drop([u'答题时长'], axis=1, inplace=True)
    d2 = pd.read_csv(filename2, encoding=encoding)
    d3 = pd.read_csv(filename3, encoding=encoding, header=None, na_filter=False)
    d3 = d3.as_matrix()
    code = {}
    for i in range(len(d3)):
        if d3[(i, 0)]:
            key = d3[(i, 0)]
            code[key] = {}
            code[key]['content'] = d3[(i, 1)]
            code[key]['qtype'] = d3[(i, 2)]
            code[key]['code'] = {}
            code[key]['qlist'] = []
        elif d3[(i, 2)]:
            tmp = d3[(i, 1)]
            if (code[key]['qtype'] in [u'多选题', u'排序题']):
                tmp = ((key + '_A') + ('%s' % tmp))
                code[key]['code'][tmp] = ('%s' % d3[(i, 2)])
                code[key]['qlist'].append(tmp)
            elif (code[key]['qtype'] in [u'单选题']):
                try:
                    tmp = int(tmp)
                except:
                    tmp = ('%s' % tmp)
                code[key]['code'][tmp] = ('%s' % d3[(i, 2)])
                code[key]['qlist'] = [key]
            elif (code[key]['qtype'] in [u'填空题']):
                code[key]['qlist'] = [key]
            else:
                try:
                    tmp = int(tmp)
                except:
                    tmp = ('%s' % tmp)
                code[key]['code'][tmp] = ('%s' % d3[(i, 2)])
    qnames_Readable = list(d1.columns)
    qnames = list(d2.columns)
    for key in code.keys():
        qlist = []
        for name in qnames:
            if (re.match((key + '_'), name) or (key == name)):
                qlist.append(name)
        if (('qlist' not in code[key]) or (not code[key]['qlist'])):
            code[key]['qlist'] = qlist
        if (code[key]['qtype'] in [u'矩阵单选题']):
            tmp = [qnames_Readable[qnames.index(q)] for q in code[key]['qlist']]
            code_r = [re.findall('_([^_]*?)$', t)[0] for t in tmp]
            code[key]['code_r'] = dict(zip(code[key]['qlist'], code_r))
    d2['start'] = pd.to_datetime(d2['start'])
    d2['finish'] = pd.to_datetime(d2['finish'])
    tmp = (d2['finish'] - d2['start'])
    tmp = tmp.astype(str).map((lambda x: ((60 * int(re.findall(':(\\d+):', x)[0])) + int(re.findall(':(\\d+)\\.', x)[0]))))
    ind = np.where((d2.columns == 'finish'))[0][0]
    d2.insert((int(ind) + 1), u'答题时长(秒)', tmp)
    return (d2, code)