pagecount = 0
filecount += 1
chunkfile = bz2.BZ2File(chunkname(filecount), 'w')
try:
    chunkfile.close()
except:
    print('Files already close')
if __name__ == '__main__':
    split_xml('wiki-files/tawiktionary-20110518-pages-articles.xml.bz2')
How to split large wikipedia dump .xml.bz2 files in Python?