CSV -> SDM Converter

Problems ? Get help here!
mamax
Posts: 19
Joined: Thu Apr 07, 2011 1:58 am
Dive Computer: Suunto

CSV -> SDM Converter

Post by mamax »

Hello,

I need to import into macdive 150 dives.
For thoses, I got only some basic datas such as date/time, location, depth, duration, type of gas and ratio O2/N2, buddies, air/water temperature, weather

I can managed thoses dives datas with a perl script to generate csv or XML file.

I try first to generate an .UDCF file, but in this case I can not insert the div duration, depth and buddies in the file (there is no elements for this)

Also I didn't find any specification of the others files formats that macdive can import such as Divelog xml or Oceanic csv...

regards
User avatar
nick
Site Admin
Posts: 4360
Joined: Sat Apr 12, 2008 8:33 am
Dive Computer: Shearwater Teric
Contact:

Re: Import dive, which is the best solution?

Post by nick »

Suunto Dive Manager .SDE is probably the best format.

If you need an example to use as a template, email me and I will send you one.
mamax
Posts: 19
Joined: Thu Apr 07, 2011 1:58 am
Dive Computer: Suunto

Re: Import dive, which is the best solution?

Post by mamax »

Thanks, it would be great
mamax
Posts: 19
Joined: Thu Apr 07, 2011 1:58 am
Dive Computer: Suunto

Re: Import dive, which is the best solution?

Post by mamax »

Hi again,

In the Suunto SDE xml file, when I have no value or data to put in a field, should I put "0" or nothing?
User avatar
nick
Site Admin
Posts: 4360
Joined: Sat Apr 12, 2008 8:33 am
Dive Computer: Shearwater Teric
Contact:

Re: Import dive, which is the best solution?

Post by nick »

It should be fine to just leave it empty, though some things will be expected to be there. You'll see errors in the console if this is the case though.
mamax
Posts: 19
Joined: Thu Apr 07, 2011 1:58 am
Dive Computer: Suunto

Re: Import dive, which is the best solution?

Post by mamax »

Hi,

Allright, it works great now.
Thanks much for your informations.


By the way, to do this i wrote a perl script which convert a CSV file to a SDE package (including ZIP compression).
Do you want I post it in the forum? Maybe it could help other people.
User avatar
nick
Site Admin
Posts: 4360
Joined: Sat Apr 12, 2008 8:33 am
Dive Computer: Shearwater Teric
Contact:

Re: Import dive, which is the best solution?

Post by nick »

Sure. I've written similar things myself, though they tend to be quite specific to a particular file format so I've never bothered to post them. And just quick hacks to get the job done.

But that would be useful - feel free to attach it. Let me know if you have any issues with the attachment settings and I'll sort it out.
mamax
Posts: 19
Joined: Thu Apr 07, 2011 1:58 am
Dive Computer: Suunto

Re: Import dive, which is the best solution?

Post by mamax »

Hi,

Please find below a perl script to convert a CSV (semi colon separated value) divelog into a Suunto dive log .sde file you can easily import to macdive
This is not a magic script but it could help most of people.

To perform the conversion you must launch the script you have to:
1) copy the perl script into the same directory of your csv divelog
2) open a terminal and go to this directory with the "cd" command
3) launch the following command :
perl csv_to_sde.pl -i dive_log.csv -o dive_log.sde
(put the file name you want for the .sde file)
4) the script will after ask for the column number of each kind of data (just press enter if none)


Concerning the CSV file you have to:
- encode the CSV file in UTF-8 (mandatory to process special char)
- have a field for the country
- have a field for the location
- have a field for the site
- the date should be in the format: dd/mm/yyyy or yyyy/mm/dd or dd-mm-yyyy or yyyy-mm-dd
- the time should be in the format: hh:mm or hh:mm:ss or hh:mm pm/am or a "h" could replace the ":"
- the dive duration should be in the format: hh:mm:ss or mm:ss or mm

If anybody need help for this script your can ask

[edit]: I just post a new version of the script, there was a bug in the previous one
Attachments
csv_to_sde.pl.zip
(3.93 KiB) Downloaded 1277 times
Last edited by mamax on Thu Jun 16, 2011 4:30 pm, edited 2 times in total.
User avatar
nick
Site Admin
Posts: 4360
Joined: Sat Apr 12, 2008 8:33 am
Dive Computer: Shearwater Teric
Contact:

Re: Import dive, which is the best solution?

Post by nick »

Thanks very much for posting this - I'm sure it will be handy.

I'll sticky this thread for you.
GKirkaldie
Posts: 29
Joined: Wed Apr 27, 2011 12:55 pm
Dive Computer: Suunto D9, Reefnet
Location: Kitchener, Ontario

Re: CSV -> SDM Converter

Post by GKirkaldie »

Hmm, I don't think this will work for me. I've exported my missing dives from Sensus Manager in CSV, but it looks to still be in their format. Temps in degrees Kelvin, depth in Kilopascals... etc...

I think I'll just wait until the next revision of the program...

Or maybe I'll look into writing my own converter script..
Post Reply