Skip to content
Snippets Groups Projects
Select Git revision
  • b1b25d00f27e3bf1a3cf121706a0f569c0f00125
  • master default protected
  • release-1.10 protected
  • replication_test
  • dev protected
  • 556-usage-statistics
  • 553-semantic-recommendation-2
  • 553-semantic-recommendation
  • release-1.9 protected
  • 551-init-broker-service-permissions
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • v1.10.4 protected
  • v1.10.3 protected
  • v1.10.2 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
41 results

list_concept.py

Blame
  • json2tsv.pl 3.16 KiB
    #!/usr/bin/perl
    
    =head1 USAGE
    
      cat data.json-lines | ./json2tsv.pl
    
    Reads individual lines which *each* contain a separate json structure
    and saves the data in TSV format.
    
    This is useful to save data from MongoDB find() statement using
    cut'n'paste.
    
    =cut
    
    use strict;
    
    use Data::Dumper;
    $Data::Dumper::Indent= 1;
    use JSON;
    use Util::tsv;
    
    my $tsv_fnm= 'data.tsv';
    my @column_names;
    
    my @PARS;
    my $arg;
    while (defined ($arg= shift (@ARGV)))
    {
      if ($arg eq '--') { push (@PARS, @ARGV); @ARGV= (); }
      elsif ($arg =~ /^--(.+)/)
      {
        my ($opt, $val)= split ('=', $1, 2);
    
           if ($opt eq 'help') { usage(); }
        elsif ($opt eq 'out') { $tsv_fnm= $val || shift (@ARGV); }
        elsif ($opt eq 'col')
        {
          $val= shift (@ARGV) unless ($val);
          push (@column_names, split (',', $val));
        }
        else { usage(); }
      }
      elsif ($arg =~ /^-(.+)/)
      {
        foreach my $opt (split ('', $1))
        {
             if ($opt eq 'h') { usage(); exit (0); }
          # elsif ($opt eq 'x') { $x_flag= 1; }
          else { usage(); }
        }
      }
      else
      {
        push (@PARS, $arg);
      }
    }
    
    my @rows;
    my %cols;
    
    if (@PARS)
    {
      foreach my $fnm (@PARS)
      {
        if (open (FI, '<:utf8', $fnm))
        {
          parse_stream(*FI, \@rows, \%cols);
          close (FI);
        } # TODO: else complain
      }