Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

wrote quick perl script to turn "new format" to old format

  • Loading branch information...
commit 45104dcafd617788d113b0bc6c85ee47ee6b5c96 1 parent b6808db
@jiwalker-usgs jiwalker-usgs authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 prms-datastore/src/main/perl/tsv2fw.pl
View
31 prms-datastore/src/main/perl/tsv2fw.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $infile = shift or die "Must supply input file\n";
+open(FILE, "<$infile");
+while (my $line = <FILE>) {
+ if ($line =~ m/^#/) {
+ $line =~ s/\r\n//;
+ print "$line\n";
+ } else {
+ if ($line =~ m/^(\w+\s+)+\w+/) {
+ # var header
+ $line =~ s/\r\n//;
+ print "$line\n";
+ } elsif ($line =~ m/^(\d+\w\s+)+\d+\w/) {
+ $line =~ s/\r\n//;
+ print "$line\n";
+ } elsif ($line =~ m/^(\d{4}-\d{2}-\d{2}:\d{2}:\d{2}:\d{2})\s+\d+(\s+[\d\.]+)+/) {
+ my @elements = split(/\s+/, $line);
+ my $len = @elements;
+ printf("%s\t", $elements[0]);
+ printf("%6d", $elements[1]);
+ for (my $i=2; $i<$len; $i++) {
+ printf("\t%1.6e", $elements[$i]);
+ }
+ print "\n";
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.