Created
February 19, 2018 21:09
-
-
Save memilanuk/c6e0bb9f98076a172d4f39d044ed6ecf 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
# bswn.py -- Munge results from BSWN events to a usable format | |
import csv | |
with open('data.txt','r') as input_file: | |
lines = input_file.read().split('\n') | |
# Remove the first 8 lines of tile, header, etc. | |
lines = lines[8:] | |
for line in lines: | |
# Strip out the class separator lines | |
if line.startswith(' '): | |
lines.remove(line) | |
with open('output.csv', 'w') as output_file: | |
fieldnames = ['name', 'class'] | |
writer = csv.DictWriter(output_file, fieldnames=fieldnames) | |
for i in range(len(lines)): | |
writer.writerow({'name': lines[i][:21], | |
'class': lines[i][22:32]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment