diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2017-07-09 11:16:28 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-15 14:44:07 +0900 |
commit | 9b7d321c8786bae7e1d4d8673ba541d7884c558b (patch) | |
tree | 72091de08ec508666f41a82e6fe42d8ccc9bfd22 /xslt/xml2csv.xslt | |
parent | 9397dbb432b3ce6d6e507370a32fd7c83b563466 (diff) | |
download | subsurface-9b7d321c8786bae7e1d4d8673ba541d7884c558b.tar.gz |
CSV export: show units on header
Let's show the units in CSV header so the actual fields have only the
values. This should be easier to parse with some other programs.
Fixes #472
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'xslt/xml2csv.xslt')
-rw-r--r-- | xslt/xml2csv.xslt | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/xslt/xml2csv.xslt b/xslt/xml2csv.xslt index 211597325..25f5d8b7c 100644 --- a/xslt/xml2csv.xslt +++ b/xslt/xml2csv.xslt @@ -7,7 +7,14 @@ <xsl:variable name="fs">,</xsl:variable> <xsl:template match="/divelog/dives"> - <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth"', $fs, '"sample temperature"', $fs, '"sample pressure"')"/> + <xsl:choose> + <xsl:when test="$units = 1"> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (ft)"', $fs, '"sample temperature (F)"', $fs, '"sample pressure (psi)"')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (m)"', $fs, '"sample temperature (C)"', $fs, '"sample pressure (bar)"')"/> + </xsl:otherwise> + </xsl:choose> <xsl:text> </xsl:text> <xsl:apply-templates select="dive|trip/dive"/> @@ -34,7 +41,7 @@ <xsl:value-of select="$fs"/> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, ' ft"')"/> + <xsl:value-of select="concat('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', round(substring-before(@depth, ' ') * 1000) div 1000, '"')"/> @@ -45,7 +52,7 @@ <xsl:if test="@temp != ''"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), ' F"')"/> + <xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', substring-before(@temp, ' '), '"')"/> @@ -57,7 +64,7 @@ <xsl:if test="@pressure != ''"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), ' psi"')"/> + <xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', substring-before(@pressure, ' '), '"')"/> |