{"id":25,"date":"2006-10-12T19:49:58","date_gmt":"2006-10-12T19:49:58","guid":{"rendered":"http:\/\/muttznutz.net\/muttzblog\/suunto-dive-manager\/integrating-sdm-16\/"},"modified":"2007-08-23T03:32:26","modified_gmt":"2007-08-23T02:32:26","slug":"integrating-sdm-16","status":"publish","type":"page","link":"https:\/\/muttznutz.net\/muttzblog\/suunto-dive-manager\/integrating-sdm-16","title":{"rendered":"Integrating SDM 1.6"},"content":{"rendered":"<p>Well, it&#8217;s fairly straightforward in principle, if you&#8217;ve played with relational databases .<br \/>\nExport the data from SDM, load it into an ODBC \/ JDBC data source, then access it from JAlbum.<br \/>\nThe Dive number is used as the key; this is attached to the photos as a structured keyword in Elements (I&#8217;ll explain that in another item).<br \/>\nThe database doesn&#8217;t have to be included on the web server &#8211; the data is incorporated into the web pages when you build the JAlbum album pages.<\/p>\n<h3>Exporting<\/h3>\n<p>This is the easy bit.<br \/>\nSelect File\/Export from the menu. Pick &#8220;ASCII in CSV format&#8221; and select a directory. The default is Suunto default &#8211; &#8220;C:\\Program Files\\SDM&#8221;. I prefer to store it somewhere else, so I created another folder in &#8220;My Documents\\My DataFiles&#8221;. Enter a file root name (We&#8217;ll assume it&#8217;s &#8220;DiveLogs&#8221;)<br \/>\nThis should create four files :<\/p>\n<table>\n<tr>\n<td>Divelogs.csv<\/td>\n<td>The main logbook file<\/td>\n<\/tr>\n<\/table>\n<table>\n<tr>\n<td>Divelogs$NOT.csv<\/td>\n<td>Free-format Notes of the dive<\/td>\n<\/tr>\n<\/table>\n<table>\n<tr>\n<td>Divelogs$PRO.csv<\/td>\n<td>Dive profile<\/td>\n<\/tr>\n<\/table>\n<table>\n<tr>\n<td>Divelogs$DGE.csv<\/td>\n<td>Dive Gear<\/td>\n<\/tr>\n<\/table>\n<p>So far, I&#8217;ve only bothered integrating the first of these files.<\/p>\n<h3>Create an ODBC \/ JDBC datasource<\/h3>\n<p>There is a Windows driver for .CSV files, but I found this a bit unreliable.<br \/>\nThe MS Excel driver was more stable, and MS Access would probably provide a stable platform. The <a href=\"http:\/\/www.microsoft.com\/sql\/editions\/express\/default.mspx\">SQL Server Express Edition<\/a> may also be suitable as a low cost solution.<br \/>\nI preferred to load the data into <a href=\"http:\/\/www.mysql.com\/\">MySQL<\/a> &#8211; partly because of the ease of loading from .csv files.<br \/>\nHowever, please don&#8217;t ask me for support on these products &#8211; I&#8217;m not that much of an expert.<\/p>\n<p>With Excel, you&#8217;ll need to insert field names in the top line of the spreadsheet, when save as an Excel file.<br \/>\nI used the following headings when using Excel:<br \/>\n[code lang=&#8221;dos&#8221;]Sequence DiveNo Dive_date Time_Down Series Dive_in_series Dive_time Surface_Interval Maximum_depth Average_depth Sample_rate_ 1 Computer_ID Personal_Information Sample_Rate_2 Gas_Model Altitude Personal_Mode Profile Location Dive_Site Weather Visibility Air_temperature Water_temperature Water_temperature_at_max Buddy1 Dive_leader Boat Tank Capacity Unknown1 Working_pressure Start_pressure End_pressure SLE_Consumption Unknown2 Dive_type Dive_school GPS Buddy Custom5 Weight NitroxO2Pct OLF OTU1CNS2[\/code]<\/p>\n<p>Note that the fields &#8220;Dive_type&#8221;,&#8221; Dive_school&#8221;,&#8221;GPS&#8221;,&#8221;Buddy&#8221; and &#8220;Custom5&#8221; are the 5 custom fields on the Dive Tab.<br \/>\nIt looks like there&#8217;s just the one format in SDM 1.6, but some of the &#8220;Unknown&#8221; fields may be used by other computer models. If you have input on this, please email me.<\/p>\n<p>I use the following script to build the table (called &#8220;divelog&#8221;) in MySQL (having set up a database called &#8220;divelogs&#8221;):<br \/>\n[code lang=&#8221;sql&#8221;]<br \/>\nDROP TABLE IF EXISTS `divelogs`.`DiveLog`;<br \/>\nCREATE TABLE `divelogs`.`DiveLog` (<br \/>\nSequence varchar(200),<br \/>\nDiveNo varchar(200),<br \/>\nDive_date date,<br \/>\nTime_Down varchar(200),<br \/>\nSeries varchar(200),<br \/>\nDive_in_series varchar(200),<br \/>\nDive_time_Seconds float,<br \/>\nSurface_Interval_Seconds float,<br \/>\nMaximum_depth varchar(200),<br \/>\nAverage_depth varchar(200),<br \/>\nSample_rate_1 varchar(200),<br \/>\nComputer_ID varchar(200),<br \/>\nPersonal_Information varchar(200),<br \/>\nSample_Rate_2 varchar(200),<br \/>\nGas_Model varchar(200),<br \/>\nAltitude varchar(200),<br \/>\nPersonal_Mode varchar(200),<br \/>\nProfile varchar(200),<br \/>\nLocation varchar(200),<br \/>\nDive_Site varchar(200),<br \/>\nWeather varchar(200),<br \/>\nVisibility varchar(200),<br \/>\nAir_temperature varchar(200),<br \/>\nWater_temperature varchar(200),<br \/>\nWater_temperature_at_max varchar(200),<br \/>\nBuddy1 varchar(200),<br \/>\nDive_leader varchar(200),<br \/>\nBoat varchar(200),<br \/>\nTank varchar(200),<br \/>\nCapacity varchar(200),<br \/>\nUnknown1 varchar(200),<br \/>\nWorking_pressure varchar(200),<br \/>\nStart_pressure varchar(200),<br \/>\nEnd_pressure varchar(200),<br \/>\nSLE_Consumption varchar(200),<br \/>\nUnknown2 varchar(200),<br \/>\nDive_type varchar(200),<br \/>\nDive_school varchar(200),<br \/>\nGPS varchar(200),<br \/>\nBuddy varchar(200),<br \/>\nCustom5 varchar(200),<br \/>\nWeight varchar(200),<br \/>\nNitroxO2Pct varchar(200),<br \/>\nOLF varchar(200),<br \/>\nOTU1CNS2 varchar(200)<br \/>\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;<br \/>\n[\/code]<\/p>\n<p>&#8230; then load the data through this script :<br \/>\n[code lang=&#8221;sql&#8221;]<br \/>\ndelete from divelogs.divelog;<br \/>\nLOAD DATA INFILE &#8216;[put your full path in here]My Documents\/My DataFiles\/Divelogs.csv&#8217;<br \/>\nREPLACE<br \/>\nINTO TABLE divelogs.divelog<br \/>\nFIELDS<br \/>\nTERMINATED BY &#8216;,&#8217;<br \/>\nOPTIONALLY ENCLOSED BY &#8216;&#8221;&#8216;<br \/>\nESCAPED BY &#8216;|&#8217;<br \/>\nLINES<br \/>\nTERMINATED BY &#8216;\\n&#8217;;<br \/>\nALTER TABLE `divelogs`.`divelog`<br \/>\nADD COLUMN `Dive_Time` TIME AFTER `OTU1CNS2`;<br \/>\nALTER TABLE `divelogs`.`divelog`<br \/>\nADD COLUMN `Surface_Interval` TIME<br \/>\nAFTER `OTU1CNS2`;<br \/>\nupdate divelogs.`DiveLog`<br \/>\nset Dive_Time =<br \/>\ncast(<br \/>\n(cast((Dive_Time_Seconds \/ 3600) as UNSIGNED) * 10000) +<br \/>\n(cast((mod(Dive_time_Seconds , 3600) \/ 60) as UNSIGNED) * 100 +<br \/>\nmod(Dive_time_Seconds, 60)<br \/>\n) as TIME) ,<br \/>\nSurface_Interval =<br \/>\ncast(<br \/>\n(cast((Surface_Interval_Seconds \/ 3600) as UNSIGNED) * 10000) +<br \/>\n(cast((mod(Surface_Interval_Seconds , 3600) \/ 60) as UNSIGNED) * 100 +<br \/>\nmod(Surface_Interval_Seconds, 60)<br \/>\n) as TIME)<br \/>\n[\/code]<br \/>\n&#8230; The last two segments convert SDM&#8217;s &#8220;seconds&#8221; based fields into TIME type fields<\/p>\n<p>Don&#8217;t forget to test the connection.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, it&#8217;s fairly straightforward in principle, if you&#8217;ve played with relational databases . Export the data from SDM, load it into an ODBC \/ JDBC data source, then access it from JAlbum. The Dive number is used as the key; this is attached to the photos as a structured keyword in Elements (I&#8217;ll explain that [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":24,"menu_order":1,"comment_status":"closed","ping_status":"open","template":"","meta":{"_mi_skip_tracking":false},"_links":{"self":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/pages\/25"}],"collection":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":0,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/pages\/25\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/pages\/24"}],"wp:attachment":[{"href":"https:\/\/muttznutz.net\/muttzblog\/wp-json\/wp\/v2\/media?parent=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}