I have two large files (8gb text file and 16 gb csv file), I want to extract random 10000 rows from each file and save in new files. i.e. random sample from text file in one file and random sample from csv in another file. I have tried Random Sample
but the problem is it is unable to save the data into a new file properly it is giving weird output (only 3 column results out of 16 columns)
f= raw_input("Enter the fp of the csv file: ")
n = sum(1 for line in open(f)) - 1 #number of records in file (excludes header)
n1=raw_input ("Enter Number of rows required in sample file")
with open(f) as mf:
head = list(islice(mf, n1))
with open('1.csv' , 'w') as out:
out.write(str(head))
any help
is highly appreciated