Skip to content

Instantly share code, notes, and snippets.

@mikeckennedy
Created June 29, 2016 18:34
Show Gist options
  • Save mikeckennedy/71ab828e8e47ebb781096e649dfee2f1 to your computer and use it in GitHub Desktop.
Save mikeckennedy/71ab828e8e47ebb781096e649dfee2f1 to your computer and use it in GitHub Desktop.
# 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