Hi Matt,
here is my attempt: Use the attached perl script or go to https://thetheoreticaldiver.org/rch-cgi-bin/smtk2ssrf.pl and select file type CSV to upload your file. Best Robert |
#!/usr/bin/perl -w use strict;
use Text::CSV;
binmode STDOUT, ":utf8";
my $csv = Text::CSV->new ( { binary => 1 , sep_char => ','} ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, "<:encoding(iso-8859-1)", $ARGV[0] or die "$ARGV[0]: $!";
my @fields = @{$csv->getline($fh)};
print "<divesites program='subsurface' version='3'>\n";
$csv->column_names(@fields);
while(my $site = $csv->getline_hr($fh)) {
next if $site->{lat} =~ /NULL/;
$site->{geog} =~ s/'//g;
print "<site name='$site->{geog}' gps='", &coordinates($site->{lat}), " ", &coordinates($site->{lon}), "'>\n</site>\n";
}
print "</divesites>\n";
sub coordinates {
my $s = shift;
my ($deg, $min) = split /\s+/, $s;
my $sign = $deg > 0 ? 1 : -1;
return $deg + $sign * int($min)/60;
}
site.xml
Description: XML document
_______________________________________________ subsurface mailing list -- [email protected] To unsubscribe send an email to [email protected]
