def file_split(file_location, divide_num, encoding='utf-8', header=True):
    """
    this function would help you split file to how many you want files evenly

    :param filelocation: would be like 'C:\\Users\\jachen\\Desktop\\projects\\dianping_web_crawler\\dianping_page_13.csv'
    :param divide_num: input the file nums you want to split, like 2,or 3
    :param encoding:  input the orininal file encoding, Default is 'utf-8'
    :param header:  should be boolean, default is True
    :return:  None
    """
    path_list = file_location.split('\\')
    file_name = path_list.pop()
    file_path = '\\'.join(path_list) + '\\'
    if header:
        print('此file有header，正在读取header...')
        original_file = open(file_location, 'r', newline='', encoding=encoding)
        file_header = original_file.readline()
        original_file.close()
        print('正在生成新的files,并写入header...')
        new_file_list = []
        for file_number in range(divide_num):
            new_file_name = file_name.split('.')[0] + '_part' + str(
                file_number + 1) + '.' + file_name.split('.')[1]
            new_file_location = file_path + new_file_name
            new_file_list.append(new_file_location)
            with open(new_file_location, 'w', newline='', encoding=encoding
                ) as new_writer:
                new_writer.write(file_header)
        print('正在逐行的拆分file，请稍后...')
        with open(file_location, 'r', newline='', encoding=encoding
            ) as original_read:
            counter = 0
            for row in original_read:
                counter += 1
                if counter >= 2:
                    pointer = int(counter % divide_num)
                    with open(new_file_list[pointer], 'a', newline='',
                        encoding=encoding) as file_object:
                        file_object.write(row)
                else:
                    pass
            print('原始文件总共有{}行记录'.format(counter))
            split_records = counter // divide_num
            print('原始文件拆成{0}个文件，每个文件大约含有{1}条记录'.format(divide_num,
                split_records))
            print('新的files是{}'.format(new_file_list))
    else:
        print('此file没有header')
        print('正在生成新的files...')
        new_file_list = []
        for file_number in range(divide_num):
            new_file_name = file_name.split('.')[0] + '_part' + str(
                file_number + 1) + '.' + file_name.split('.')[1]
            new_file_location = file_path + new_file_name
            new_file_list.append(new_file_location)
        print('正在逐行的拆分file，请稍后...')
        with open(file_location, 'r', newline='', encoding=encoding
            ) as original_read:
            counter = 1
            for row in original_read:
                pointer = int(counter % divide_num)
                with open(new_file_list[pointer], 'a', newline='', encoding
                    =encoding) as file_object:
                    file_object.write(row)
                counter += 1
            print('原始文件总共有{}行记录'.format(counter))
            split_records = counter // divide_num
            print('原始文件将会拆成{0}个文件，每个文件大约含有{1}条记录'.format(divide_num,
                split_records))
            print('新的files是{}'.format(new_file_list))
