The script would take in the input file with multiple rows and would give a row count. This can then be used to decide on the number of segmented files that would need to be generated based on the required number of rows in each file. Please note that I shall be making a GUI version of the same soon for simplifying use.
#!/usr/bin/env python # encoding: utf-8 import sys from math import * import os import random from Tkinter import * import tkFileDialog def linesplit(): line=0 k1=tkFileDialog.askopenfilename() ff=open(k1) for lineee in ff: line=line+1 print "total number of lines is:"+str(line) ff.close() line=0 user_ask=raw_input("Specify the number of records in each file = ") user_ask=eval(user_ask) print user_ask ff=open(k1) i=1 temp=user_ask for lineee in ff: line=line+1 temp_filename="c:\Temp\split_"+str(i)+".txt" if(line < user_ask): ff1=open(temp_filename,'a+') ff1.write(lineee) ff1.close() if(line == user_ask): user_ask=user_ask+temp i=i+1 ff.close() flag=1 return (line,flag) k=linesplit() flag=k[1]