python碎片|账本自动分页分行源码

%title插图%num#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# @Author : zhenbei
# @File : konggang.py
# @Time : 2021/1/11 17:20

import pandas as pd

dat = pd.read_csv(r’C:\Users\giser\Desktop\9.csv’, encoding=’gbk’)
dt = dat.groupby(dat[‘SCODE ‘])
scode = pd.DataFrame(dt.count())
li = scode[‘SID ‘]
s = []
l = []
for i in li:
p = [(c – 1) // 15 + 1 for c in range(1, i + 1)]
s.extend(p)

for a in li:
for b in range(1, a // 15 + 1):
for m in range(1, 16):
l.append(m)
for n in range(1, a – 15 * (a // 15) + 1):
l.append(n)
dat[‘PAGE ‘] = s
dat[‘LINE ‘] = l
dat.to_csv(r’C:\Users\giser\Desktop\res.csv’, encoding=’gbk’)