Use Python Write Script Perform Following Task Use Simplest Way Come Program Script Takes Q37136593

Use python to write a script to perform the following task. Usethe simplest way you can come up with. Your program/script takestwo inputs: a file (containing single column tokens) and a numberwhich will be the number of columns in the output (example belowshows 3 columns): input file: t1 t2 t3 t4 t5 … many more tokensoutput : t1 t2 t3 t4 t5 t6 …..


Solution


#CODE with comments STARTS

import sys

filename = sys.argv[1] #filename to store filename from 1stargument to the script

columns = int(sys.argv[2]) #columns to store number of columnsin the output

file = open(‘test.txt’, ‘r’) #opening the file in read mode(‘r’)

count

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.