Hi Matt,

On 17. Oct 2025, at 16:28, Matt Wilbur <[email protected]> wrote:

A snippet is attached. I can easily remove all the entries with NULL lat/long.  

My source was the REEF.org organization (I volunteer for them and do fish surveys), and unfortunately I'm not allowed the share the data- I suspect it may have been gathered with the help of boat captains who don't like to give up the locations.  I will ask them again if they would consider sharing the data with the community, as its the most comprehensive pile of dive sites I'm aware of.

So right now unlikely others would use this data-- although a general utility to import sites from files like this (I also have sites and drop points stored in my garmin descent I could export to gpx files and import as site) I think would have utility to many.



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;
}

Attachment: site.xml
Description: XML document

_______________________________________________
subsurface mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to