mercredi 19 octobre 2016

Reading random inputs from a csv and moving it to another csv

i'm new to python so just bear with me here. I have a CSV file 'A.csv' with 1000 rows of data. I need to select some rows from A at random (by making use of a random function) and move it into another file 'B.csv' with same header as that of A. The only restriction is that i'm not allowed to load the the entire content of A into memory i.e., i can't a use a statement like "pd.read_csv('A.csv',header=....)", "pd.to_csv(....)" etc. I am only allowed to load the randomly selected data from A into memory to transfer them to file B. I need to do this in python.

P.S. I need a code that uses the least amount of memory.




Aucun commentaire:

Enregistrer un commentaire