I need to split a large xml file (18GB) into 3 smaller files while maintaining the original xml structure. All elements in the file fall under a single root element.
I've been successful using the readlines() method, however, I'm wondering if there is a better way to do this using Python.
My code thus far:
with open(r'largefilepath.xml', 'r') as myfile, open(r'release_sample2.xml', 'w') as outfile:
sampleslice = myfile.readlines(100000)
for line in sampleslice:
outfile.write(line)
No comments:
Post a Comment