samedi 16 juillet 2016

split every 50,000 lines and write file in python


I read files which contains 75,151 lines. I want to split every 50,000 lines. So I made 2 files, one files have 50,000 lines and the other file has 25,151 lines. I made code like this (INSERT_NUMBER : 50,000) for index, data in enumerate(lines): if ((index % INSERT_NUMBER) == 0 and index != 0) or (index == (lines- 1)) : made file .... which is the better way to split every 50,000 lines and make new files ?

Aucun commentaire:

Enregistrer un commentaire