Created
December 3, 2019 03:56
-
-
Save sagorbrur/ce10c55cefd2dbc8d51d13b08a72ba62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from tqdm import tqdm | |
| count = 0 | |
| for root, dirs, files in tqdm(os.walk("/path")): | |
| for file in files: | |
| if file.endswith(".txt"): | |
| # print(file) | |
| filename = "files/text_{}".format(count) | |
| output = open(filename, "w") | |
| path = os.path.join(root, file) | |
| # print(path) | |
| text = open(path, "r").read() | |
| output.write(text) | |
| count+=1 | |
| output.close() | |
| print("Total text file found: ", count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment