CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Please help with a PERL Script for Google Voice Call Log (Google Takeout)

 



yorktown
New User

Aug 2, 2012, 4:43 PM

Post #1 of 1 (801 views)
Please help with a PERL Script for Google Voice Call Log (Google Takeout) Can't Post

Using Google Takeout, I downloaded my Google Voice call logs.

Google does that in a very wierd way (for some, this is not surprising). The call log consists of a "Call" directory in which each call is an individual HTML file.

So if you made 855 calls, you have 855 .html files in the directory.

I want the list in an excel spreadsheet like this:


Quote
Date Time Type User Number Duration
02-Aug-2012 20:44:22 Placed Joe Smith 12035551212 0:00:17


My original perl code (below) goes through each .html file and produces a single spreadsheet called calls2.xls
....but Google changed the way they produce the HTML files....

Now.. the PERL script gives me everything but the DATE and TIME
(I am using this on a Win7 Machine with ActivePerl)

Any help getting the Date and Time in the excel spreadsheet would be great.

PERL CODE (Outside the 'Calls' Directory):


Code
#!/usr/bin/perl -w 
$ncalls = 0;
$path = "Calls";
opendir(DIR, $path) or die "can't open $path folder";
open(OUT, ">calls2.csv") or die "can't write CSV file";
print OUT "Date,Time,Type,User,Number,Duration\n";
for $fname (readdir(DIR)) {
next unless $fname =~ /\.html$/ && open(IN, "$path\/$fname");
$date = $time = $type = $user = $number = $duration = '';
while (<IN>) {
$user = <IN>, $user =~ s/<.+\n// if /Call Log for/;
$type = $1 if />(Placed|Received|Missed|Voicemail) (call |from)/;
$number = $1 if /tel:\+(\d+)/;
$date =~ s#(\d+)/(\d+)/(\d+)#$3/$1/$2#;
$time = $1 if />([\w,: ]+)<\/abbr>/;
$duration = '00:00:00' if $type eq 'Missed' && $date;
$duration = $1 if />\(([\d:]+)\)<\/abbr>/;
if ($duration) {
print OUT "\"$date\",\"$time\",$type,\"$user\",$number,$duration\n";
++$ncalls;
last;
}
}
}
print "processed $ncalls calls\n";



In the calls directory attached are how 2 .html files look:

Received call:
Filename: +15165551212_-_2012-07-23T14-47-35Z.html

This is a placed call:
Filename : +14085551213_-_2012-07-30T16-18-44Z.html


(This post was edited by yorktown on Aug 2, 2012, 11:38 PM)
Attachments: del1-recd-call.html (1.68 KB)
  del2-placed-call.html (1.66 KB)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives