summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--dives/TestComma.csv27
-rw-r--r--file.c8
-rw-r--r--qt-ui/csvimportdialog.cpp2
-rw-r--r--xslt/csv2xml.xslt8
5 files changed, 43 insertions, 4 deletions
diff --git a/dive.h b/dive.h
index 7f3a55a99..0ee3a1aa6 100644
--- a/dive.h
+++ b/dive.h
@@ -626,7 +626,7 @@ extern void set_filename(const char *filename, bool force);
extern int parse_dm4_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error);
extern void parse_file(const char *filename, char **error);
-extern void parse_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, int stopdepthf, char **error);
+extern void parse_csv_file(const char *filename, int time, int depth, int temp, int po2f, int cnsf, int stopdepthf, int sepidx, char **error);
extern void save_dives(const char *filename);
extern void save_dives_logic(const char *filename, bool select_only);
diff --git a/dives/TestComma.csv b/dives/TestComma.csv
new file mode 100644
index 000000000..2294a7001
--- /dev/null
+++ b/dives/TestComma.csv
@@ -0,0 +1,27 @@
+Dive Time (s),Depth (m),PPO2 - Setpoint (Bar),PPO2 - C1 Cell 1 (Bar),PPO2 - C1 Cell 2 (Bar),PPO2 - C1 Cell 3 (Bar),PPO2 - C1 Measured (Bar),PPO2 - C2 Cell 1 (Bar),PPO2 - C2 Cell 2 (Bar),PPO2 - C2 Cell 3 (Bar),PPO2 - C2 Measured (Bar),C1 Battery 1 (Volts),C1 Battery 2 (Volts),C2 Battery 1 (Volts),C2 Battery 2 (Volts),Ambient Temp. (Celcius),OTU Exposure (%),CNS Exposure (%),Deco Ceiling (m),Gradient Factor
+0,0.0,0,0,0,0,0,0,0,0,0,0,0,0,0,19.00,0,0,0,0
+60,2.5,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+120,4.5,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+180,5.0,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+240,5.5,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+300,5.0,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+360,5.5,0,0,0,0,0,0,0,0,0,0,0,0,0,17.00,0,0,0,0
+420,7.0,0,0,0,0,0,0,0,0,0,0,0,0,0,17.00,0,0,0,0
+480,9.0,0,0,0,0,0,0,0,0,0,0,0,0,0,17.00,0,0,0,0
+540,11.5,0,0,0,0,0,0,0,0,0,0,0,0,0,16.00,0,0,0,0
+600,11.5,0,0,0,0,0,0,0,0,0,0,0,0,0,16.00,0,0,0,0
+660,12.5,0,0,0,0,0,0,0,0,0,0,0,0,0,16.00,0,0,0,0
+720,13.5,0,0,0,0,0,0,0,0,0,0,0,0,0,16.00,0,0,0,0
+780,16.0,0,0,0,0,0,0,0,0,0,0,0,0,0,15.00,0,0,0,0
+840,17.0,0,0,0,0,0,0,0,0,0,0,0,0,0,15.00,0,0,0,0
+900,18.0,0,0,0,0,0,0,0,0,0,0,0,0,0,15.00,0,0,0,0
+960,18.5,0,0,0,0,0,0,0,0,0,0,0,0,0,15.00,0,0,0,0
+1020,20.0,0,0,0,0,0,0,0,0,0,0,0,0,0,15.00,0,0,0,0
+1080,18.5,0,0,0,0,0,0,0,0,0,0,0,0,0,15.00,0,0,0,0
+1140,16.0,0,0,0,0,0,0,0,0,0,0,0,0,0,16.00,0,0,0,0
+1200,10.5,0,0,0,0,0,0,0,0,0,0,0,0,0,17.00,0,0,0,0
+1260,5.0,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+1320,4.0,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+1380,2.0,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+1440,1.5,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
+1460,0.0,0,0,0,0,0,0,0,0,0,0,0,0,0,18.00,0,0,0,0
diff --git a/file.c b/file.c
index 5f9b3d90a..aaf14f3d9 100644
--- a/file.c
+++ b/file.c
@@ -327,17 +327,18 @@ void parse_file(const char *filename, char **error)
#define MAXCOLDIGITS 3
#define MAXCOLS 100
-void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int stopdepthf, char **error)
+void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int po2f, int cnsf, int stopdepthf, int sepidx, char **error)
{
struct memblock mem;
int pnr=0;
- char *params[17];
+ char *params[19];
char timebuf[MAXCOLDIGITS];
char depthbuf[MAXCOLDIGITS];
char tempbuf[MAXCOLDIGITS];
char po2buf[MAXCOLDIGITS];
char cnsbuf[MAXCOLDIGITS];
char stopdepthbuf[MAXCOLDIGITS];
+ char separator_index[MAXCOLDIGITS];
time_t now;
struct tm *timep;
char curdate[9];
@@ -356,6 +357,7 @@ void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int
snprintf(po2buf, MAXCOLDIGITS, "%d", po2f);
snprintf(cnsbuf, MAXCOLDIGITS, "%d", cnsf);
snprintf(stopdepthbuf, MAXCOLDIGITS, "%d", stopdepthf);
+ snprintf(separator_index, MAXCOLDIGITS, "%d", sepidx);
time(&now);
timep = localtime(&now);
strftime(curdate, sizeof(curdate), "%Y%m%d", timep);
@@ -380,6 +382,8 @@ void parse_csv_file(const char *filename, int timef, int depthf, int tempf, int
params[pnr++] = curdate;
params[pnr++] = "time";
params[pnr++] = curtime;
+ params[pnr++] = "separatorIndex";
+ params[pnr++] = separator_index;
params[pnr++] = NULL;
if (filename == NULL)
diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/csvimportdialog.cpp
index 91b9ddd40..b3392f421 100644
--- a/qt-ui/csvimportdialog.cpp
+++ b/qt-ui/csvimportdialog.cpp
@@ -22,6 +22,7 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
ui->knownImports->addItem(CSVApps[i].name);
ui->CSVSeparator->addItem("Tab");
+ ui->CSVSeparator->addItem(",");
ui->knownImports->setCurrentIndex(1);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
@@ -52,6 +53,7 @@ void CSVImportDialog::on_buttonBox_accepted()
VALUE_IF_CHECKED(CSVpo2),
VALUE_IF_CHECKED(CSVcns),
VALUE_IF_CHECKED(CSVstopdepth),
+ ui->CSVSeparator->currentIndex(),
&error);
if (error != NULL) {
diff --git a/xslt/csv2xml.xslt b/xslt/csv2xml.xslt
index fda0b6724..7ddbda92d 100644
--- a/xslt/csv2xml.xslt
+++ b/xslt/csv2xml.xslt
@@ -11,11 +11,17 @@
<xsl:param name="stopdepthField" select="stopdepthField"/>
<xsl:param name="date" select="date"/>
<xsl:param name="time" select="time"/>
+ <xsl:param name="separatorIndex" select="separatorIndex"/>
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="lf"><xsl:text>
</xsl:text></xsl:variable>
- <xsl:variable name="fs"><xsl:text> </xsl:text></xsl:variable>
+ <xsl:variable name="fs">
+ <xsl:choose>
+ <xsl:when test="$separatorIndex = 0"><xsl:text> </xsl:text></xsl:when>
+ <xsl:otherwise><xsl:text>,</xsl:text></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
<xsl:template match="/">
<divelog program="subsurface-import" version="2">