Skip to content

Instantly share code, notes, and snippets.

@michellechandra
Created March 12, 2014 02:05
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 michellechandra/85799eee2ac07ed310dd to your computer and use it in GitHub Desktop.
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.
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