Page 1 of 3

CSV -> SDM Converter

Posted: Thu May 12, 2011 4:31 pm
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

Re: Import dive, which is the best solution?

Posted: Thu May 12, 2011 4:33 pm
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.

Re: Import dive, which is the best solution?

Posted: Thu May 12, 2011 6:03 pm
by mamax
Thanks, it would be great

Re: Import dive, which is the best solution?

Posted: Fri May 13, 2011 7:30 pm
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?

Re: Import dive, which is the best solution?

Posted: Sat May 14, 2011 4:53 am
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.

Re: Import dive, which is the best solution?

Posted: Mon May 16, 2011 3:26 pm
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.

Re: Import dive, which is the best solution?

Posted: Mon May 16, 2011 3:31 pm
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.

Re: Import dive, which is the best solution?

Posted: Wed May 18, 2011 4:40 am
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

Re: Import dive, which is the best solution?

Posted: Wed May 18, 2011 5:12 am
by nick
Thanks very much for posting this - I'm sure it will be handy.

I'll sticky this thread for you.

Re: CSV -> SDM Converter

Posted: Wed May 18, 2011 6:37 am
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..