Skip to content

Commit

Permalink
make the example modencode faceted tracksel use the modencode data in…
Browse files Browse the repository at this point in the history
… CSV format
  • Loading branch information
rbuels committed Jun 12, 2012
1 parent 76af1a2 commit 0f82c5f
Show file tree
Hide file tree
Showing 3 changed files with 1,892 additions and 2 deletions.
22 changes: 22 additions & 0 deletions sample_data/json/modencode/modencode2csv.pl
@@ -0,0 +1,22 @@
#!/usr/bin/env perl
use strict;
use warnings;
use autodie ':all';
use 5.10.0;

use JSON 2;

my $data = from_json( do { local $/; open my $f, '<', $ARGV[0]; scalar <$f> } );

my @fields = qw( technique factor target principal_investigator submission label category type Developmental-Stage organism key );

say join ',', map "\"$_\"", @fields;

for my $item ( @{$data->{items}} ) {
$item->{key} = $item->{label};
no warnings 'uninitialized';
for my $track ( @{$item->{Tracks}} ) {
$item->{label} = $track;
say join ',', map "\"$_\"", @{$item}{@fields};
}
}

0 comments on commit 0f82c5f

Please sign in to comment.