Created
November 26, 2015 05:43
-
-
Save iandioch/6f0e9ea91946792aa4a2 to your computer and use it in GitHub Desktop.
Grabs just the tweet text from sentiment140 tweet corpus and discards the noise
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
# loads the CSV corpus file from the links here (http://help.sentiment140.com/for-students) and outputs just the tweet text | |
lines = [] | |
with open("testdata.manual.2009.06.14.clean.txt", "w") as outfile: | |
with open("testdata.manual.2009.06.14.csv", 'r') as infile: | |
lines = infile.readlines() | |
for line in lines: | |
bits = line.split(",") | |
text = ",".join(bits[5:]).replace("&", "&").replace("<", "<").replace(">", ">") | |
text = text[1:-2] | |
print text | |
outfile.write(text + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment