Question: In python write a function called file_split() which takes two parameters: file name, and number of splits the function should take a file and split
In python write a function called file_split() which takes two parameters: file name, and number of splits the function should take a file and split it into new files based on the number of lines.
When the length is not evenly divisible all output files length must not have a difference greater than 1. For example, a file of 10 lines, split in 3, would have output files of length 3, 3 and 4.
for example:
File_split(Numbers.txt, 3) Should split the file Numbers.txt into three files named output_1.txt, output_2.txt, output 3.txt... etc




Numbers.txt 1 2 3 4 8 9 10 11 12 13 14 15 16 17 18 19 20 output_1.txt 1 2 3 4 5 6 output_2.txt 8 9 10 11 12 13 14 output_3.txt 15 16 17 18 19 20 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
