Created
June 29, 2016 18:34
-
-
Save mikeckennedy/71ab828e8e47ebb781096e649dfee2f1 to your computer and use it in GitHub Desktop.
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
# Parse this busted file: | |
# | |
# A,B,C,D,E, | |
# A,B,C,D,E, | |
# A,B,C,D,E, A,B,C,D,E, | |
# | |
# A,B,C,D,E, | |
# A,B,C,D,E, | |
data = [] | |
with open('busted.txt') as fin: | |
for line in fin: | |
parts = [w.strip() for w in line.split(',') if w.strip()] | |
while parts: | |
entry = parts[:5] | |
parts = parts[5:] | |
data.append(",".join(entry)) | |
print(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment