File: transform.pl

package info (click to toggle)
rickshaw 1.5.1.dfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,864 kB
  • sloc: javascript: 15,281; makefile: 97; perl: 59
file content (25 lines) | stat: -rwxr-xr-x 406 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env perl

use warnings;
use strict;

my @header;
my $data;

while (<>) {

	# the third line is the header
	if ($. == 3) {
		          # and we want the years
		@header = map { m/^(\d{4})/; $1; }
	              (split ',')[1..11];
	}

	if (m/^United States/) {
		my $i = -1;
		$data = "[ " . join(", ", map { "{ x: $header[++$i], y: $_ }" } (split ',')[1..11]) . " ]";
		last;
	}
}

print $data;