Mar-29-2017, 11:35 PM
I'd like to thank everybody for being so supportive and helpful. The task has been accomplished with the following code:
file_counter = 0 for dirpath, dirname, files in os.walk('/Users/mymac/Documents/Jupyter/Twitter/1 day test'): for filename in files: file_counter += 1 if filename.endswith('.json.bz2'): filepath = os.path.join(dirpath, filename) newfilepath = os.path.join(dirpath, "{0}.json".format(file_counter)) print(newfilepath) with open(newfilepath, 'wb') as new_file, bz2.BZ2File(filepath, 'rb') as file: for data in iter(lambda : file.read(100 * 1024), b''): new_file.write(data)