import csv

import pandas as pd

# filePath=r'D:\hg\2023\08\累计\贸易伙伴\202301-08--贸易伙伴--进口-307.csv'
# # codes=[]
# with open(filePath) as csvfile:
#
#     reader = csv.reader(csvfile)
#     #跳过第一条数据
#     # next(reader)
#     try:
#         for row in reader:
#             # 进行数据处理
#             print(row)
#     except csv.Error as e:
#         # 打印错误信息
#         print(f'Error reading CSV file: {e}')
#
# filePathName='test.csv'
# # 打开输入文件和输出文件
# with open(filePath, 'r') as input_csv, open(filePathName, 'w', newline='') as output_csv:
#     # 创建CSV读取器和写入器
#     csv_reader = csv.reader(input_csv)
#     csv_writer = csv.writer(output_csv)
#     # 逐行读取输入文件，并将每一行写入输出文件
#     for row in csv_reader:
#         csv_writer.writerow(row)

def group_elements(codes):
    groups = [codes[i:i+8] for i in range(0, len(codes), 8)]
    result = [','.join(group) for group in groups]
    return result
cc=['12','13','12','15','1','2','3','4','6','8','9']
aa=group_elements(codes=cc)
print(aa)
