Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@aallan /
Last active

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Perl script to go through the leaked Snapchat database of phone numbers and user names, and divide it into separate CSV files split by location. Will create a file for each location in a locations/ subdirectory in the current working directory. Will report the totals for each location in CSV format.
use strict;
print "Reading schat.csv\n";
unless ( open ( FILE, "<schat.csv") ) {
print "Cannot open file for read\n";
my @foo = <FILE>;
chomp( @foo );
close FILE;
print "Checking for locations directory\n";
mkdir "locations" unless -d "locations";
print "Processing...\n";
my %locations;
foreach my $foo ( @foo ) {
$foo =~ s/"$//;
$foo =~ s/^"//;
$foo =~ s/","/,/g;
my @bar = split ",", $foo;
if( exists $locations{$bar[2]} ) {
$locations{$bar[2]} += 1;
} else {
$locations{$bar[2]} = 1;
unless ( open ( FILE, ">>locations/$bar[2].csv") ) {
print "Cannot open $bar[2].csv for write";
print FILE "$foo\n";
my $total = 0;
foreach my $key (sort keys %locations) {
print "$key,$locations{$key}\n";
$total = $total + $locations{$key};
print "Total = $total\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.