When dividing a file with a known number of lines by a specified number, find out how to divide it.
py
total=100 #Total number of lines
div = 7 #Division number
div_list = [ (total//div) + (1 if x <(total%div) else 0) for x in range(div)]
# div_list = [15, 15, 14, 14, 14, 14, 14]
In the above example, if you divide a file with 100 lines into 7 files, You can divide it into two files with 15 lines and five files with 14 lines.
Recommended Posts