Skip to content

Instantly share code, notes, and snippets.

@laszlo91
Last active August 29, 2015 14:27
Show Gist options
  • Save laszlo91/c0adc4f0c1fb5bc4912a to your computer and use it in GitHub Desktop.
Save laszlo91/c0adc4f0c1fb5bc4912a to your computer and use it in GitHub Desktop.
Make a two columns spreadsheet (user and text, comma separated) from a single line html of your facebook conversation. User: guy you chat with. Text: what you write to him.
# by phil Bonora for nlpspoiler.it
use strict;
use warnings;
use utf8;
my @t;
my $name="PUT YOUR NAME HERE"; #STDIN html (all in one line)
print "user,text\n2";
while (my $ligne = <STDIN>) {
chomp $ligne;
while ($ligne =~ /<.[^<>]*>(.[^<>]*)<.[^<>]*>/g ) {
if ($1 !~/[MTWFS]\w+day,\s\d+\s.*$/){
push (@t, $1);
}
}
}
my $loc;
my $txt;
for (my $i=0; $i<=$#t; $i++){
if ($t[$i]=~/$name,\s(.[^,]*)$/ or $t[$i]=~/(.[^,]*),\s$name$/ ){
print "\n";
$loc=$1;
print "$loc,";
}
elsif ($t[$i]=~/$name$/){
print "$t[$i+1] | ";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment