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

In python write a function called file_split() which takes two parameters: filename, and number of splits the function should take a file andsplit it into new files based on the number of lines. Whenthe length is not evenly divisible all output files length must not

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!