Skip to content

Instantly share code, notes, and snippets.

@TheConnMan
Created June 10, 2014 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheConnMan/855b79f4595462cf5093 to your computer and use it in GitHub Desktop.
Save TheConnMan/855b79f4595462cf5093 to your computer and use it in GitHub Desktop.
Some Python to parse out those pesky characters
Stuff Moar Stuff So Much -Stuff
St-uff Moar Stuff So Much| Stuff
Stuff Moar |Stuff So Much Stuff
St|uff Mo-ar Stuff So -Much Stuff
Stuff Moar Stu|ff So Much Stuff
St-uff Moar Stuf-f So Much |S-tuff
Stuff Moar -Stuf-f So- Much Stuff
St|uf-f Moar Stuf|f So Much Stuff
Stuff |Moar -Stuff So- Much |Stuff
Stuff Moar S|tuff So Muc|h Stuff
import csv
# Open the raw file
fileReader=open('ParseDis.csv','rb')
# Open the writer
writer=open('DisBeParsed.csv','wb')
# Read the raw file as a CSV
reader=csv.reader(fileReader)
replaceDees=['-','|']
# Get all rows
for row in reader:
line=''
# Get all rows
for col in row:
# Get a character to replace
for i in replaceDees:
# Replace it
col=col.replace(i,'')
# Replace it good
# Add it to the current line
line+=col+','
# Write the line
writer.write(line+'\n')
# Shut it down
fileReader.close()
writer.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment