Question: (1) The below shell script creates a file file1.txt with one million records of random numbers: for i in {1..1000000} do echo $RANDOM >> file1.txt

(1) The below shell script creates a file "file1.txt" with one million records of random numbers:

for i in {1..1000000} do echo $RANDOM >> file1.txt done

(2) The below Python code reads record from above "file1.txt", then calculates the double of that number and then write the result in "file2.txt":

f1 = open("file1.txt",'r') all_lines = f1.readlines()

f2 = open("file2.txt",'w') dn = 0

for l in all_lines: dn = int(l) * 2 f2.write(str(dn) + ' ')

f2.close()

(3) Need a complete Python code which breaks the input file "file1.txt" (from above) into 5 files/chunks and then do a real-time scheduling of the Python code (mentioned in Part-2) on each chunk and finally combine the resulting files into a single output file.

NOTE: Please don't give pseudo code but provide an actual Python code.

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!