Created
March 2, 2019 08:48
-
-
Save pyohei/74390df1428bdc61b330e6ebd51e97d8 to your computer and use it in GitHub Desktop.
Separate combined text file.
This file contains 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
"""This text contain `----fileName` as break point.""" | |
FILE_NAME = 'all.txt' | |
with open(FILE_NAME, mode='r') as f: | |
_f = None | |
for line in f.readlines(): | |
if line.startswith('----'): | |
if _f: | |
_f.close() | |
_file_name = line.lstrip('-').rstrip('\r\n') | |
_f = open('test/' + _file_name, 'w') | |
else: | |
_f.write(line) | |
if _f: | |
_f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment