-
-
Save michellechandra/85799eee2ac07ed310dd to your computer and use it in GitHub Desktop.
Parse ITP listserv emails into an IntDict to see how often individuals have emailed the ITP listserv.
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
BufferedReader reader; | |
IntDict initiators = new IntDict(); | |
void setup() { | |
String directory = "/Users/michellechandra/Documents/ITP Spring 2013/Rest of You/listy_partdeux/data/"; | |
//String directory = "/Volumes/Crucial/ThesisTXT/"; | |
size(800, 800); | |
// String directory = "D:\\ThesisTXT\\"; | |
File dir = new File(directory); | |
String[] files = dir.list(); | |
int okayFile = 0; | |
String lastSubject = ""; | |
for (int i=0; i<files.length; i++) { | |
// Get filename of file or directory | |
String line = ""; | |
String From = ""; | |
String Subject = ""; | |
okayFile++; | |
String filename = files[i]; | |
if (filename.endsWith(".txt")) { | |
println(filename); | |
reader = createReader(directory + filename); | |
int count = 0; | |
while (true) { | |
try { | |
line = reader.readLine(); | |
if (line.startsWith("Subject:")) Subject = line; | |
if (line.startsWith("From:")) From = line; | |
//println(line); | |
count++; | |
} | |
catch (IOException e) { | |
e.printStackTrace(); | |
line = null; | |
} | |
if (!(Subject.equals("") || From.equals("")) || count > 100) break; | |
} | |
if(Subject != lastSubject){ | |
//add to intDict | |
initiators.increment(From); | |
lastSubject = Subject; | |
} | |
// println(Subject); | |
// println(From); | |
// println("XXXXXXXXXXXXXXXXXXXXX"); | |
initiators.sortValues(); | |
println(initiators); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment