Skip to content

Commit 6bf5591

Browse files
author
R. S. Doiel
committed
Merge branch 'main' of github.com:caltechlibrary/datatools into gh-pages
2 parents 833cff2 + 0aa88a1 commit 6bf5591

164 files changed

Lines changed: 1037 additions & 237 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CodeMeta2CFF
2+
run-name: Run CodeMeta2CFF after ${{github.event_name}} by ${{github.actor}}
3+
4+
on:
5+
push:
6+
paths: ['codemeta.json']
7+
workflow_dispatch:
8+
inputs:
9+
reason:
10+
description: 'Reason'
11+
required: false
12+
default: 'Manual trigger'
13+
14+
jobs:
15+
CodeMeta2CFF:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Convert CFF
23+
uses: caltechlibrary/codemeta2cff@main
24+
- name: Commit CFF
25+
uses: EndBug/add-and-commit@v9
26+
with:
27+
message: 'Add updated CITATION.cff from codemeta.json file'
28+
add: 'CITATION.cff'

CITATION.cff

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ message: "If you use this software, please cite it as below."
33
type: software
44
title: "datatools"
55
abstract: "A set of command line tools for working with CSV, Excel
6-
Workbooks, JSON and structured text documents."
6+
Workbooks, JSON and structured text documents. Included are tools for
7+
handling urlencoding and urldecoding as well as path relationships on
8+
the file system and in URLs"
79
authors:
810
- family-names: Doiel
911
given-names: R. S.
@@ -15,7 +17,7 @@ maintainers:
1517
orcid: ""
1618

1719
repository-code: "https://github.com/caltechlibrary/datatools"
18-
version: 1.3.4
20+
version: 1.3.5
1921
license-url: "https://data.caltech.edu/license"
20-
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
21-
date-released: 2025-05-15
22+
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash", "url", "urlencoding" ]
23+
date-released: 2026-02-12

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ RELEASE_DATE=$(shell date +'%Y-%m-%d')
99

1010
RELEASE_HASH=$(shell git log --pretty=format:'%h' -n 1)
1111

12-
PROGRAMS = codemeta2cff csv2json csv2jsonl csv2mdtable csv2tab csv2xlsx csvcleaner csvcols csvfind csvjoin csvrows finddir findfile json2toml json2yaml jsoncols jsonjoin jsonmunge jsonrange jsonobjects2csv json2jsonl mergepath range reldate reltime sql2csv string tab2csv timefmt toml2json urlparse xlsx2csv xlsx2json yaml2json
12+
PROGRAMS = codemeta2cff csv2json csv2jsonl csv2mdtable csv2tab csv2xlsx csvcleaner csvcols csvfind csvjoin csvrows finddir findfile json2toml json2yaml jsoncols jsonjoin jsonmunge jsonrange jsonobjects2csv json2jsonl mergepath range reldate reltime sql2csv string tab2csv timefmt toml2json urlparse xlsx2csv xlsx2json yaml2json urldecode urlencode reldocpath
1313

14-
MAN_PAGES = codemeta2cff.1 csv2json.1 csv2jsonl.1 csv2mdtable.1 csv2tab.1 csv2xlsx.1 csvcleaner.1 csvcols.1 csvfind.1 csvjoin.1 csvrows.1 finddir.1 findfile.1 json2toml.1 json2yaml.1 jsoncols.1 jsonjoin.1 jsonmunge.1 jsonrange.1 jsonobjects2csv.1 json2jsonl.1 mergepath.1 range.1 reldate.1 reltime.1 sql2csv.1 string.1 tab2csv.1 timefmt.1 toml2json.1 urlparse.1 xlsx2csv.1 xlsx2json.1 yaml2json.1
14+
MAN_PAGES = codemeta2cff.1 csv2json.1 csv2jsonl.1 csv2mdtable.1 csv2tab.1 csv2xlsx.1 csvcleaner.1 csvcols.1 csvfind.1 csvjoin.1 csvrows.1 finddir.1 findfile.1 json2toml.1 json2yaml.1 jsoncols.1 jsonjoin.1 jsonmunge.1 jsonrange.1 jsonobjects2csv.1 json2jsonl.1 mergepath.1 range.1 reldate.1 reltime.1 sql2csv.1 string.1 tab2csv.1 timefmt.1 toml2json.1 urlparse.1 xlsx2csv.1 xlsx2json.1 yaml2json.1 urldecode.1 urlencode.1 reldocpath.1
1515

1616
PACKAGE = $(shell ls -1 *.go)
1717

@@ -215,6 +215,7 @@ gen_batfiles: .FORCE
215215
snap: dist/datatools_$(VERSION)_amd64.snap
216216

217217
release: .FORCE clean build man gen_batfiles distribute_docs dist/Linux-armv7l dist/Linux-aarch64 dist/Linux-x86_64 dist/macOS-x86_64 dist/macOS-arm64 dist/Windows-x86_64 dist/Windows-arm64
218+
git pull origin $(BRANCH)
218219
echo "ready to run ./release.bash"
219220

220221

README.md

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
datatools
33
=========
44

5-
_datatools_ is a rich collection of command line programs targetting
5+
_datatools_ is a rich collection of command line programs targeting
66
data conversion, cleanup and analysis directly from your favorite
7-
POSIX shell. It has proven useful for data collaberations where
8-
individual members of a project may prefer different toolsets in their
7+
POSIX shell or Powershell. It has proven useful for data collaborations where
8+
individual members of a project may prefer different tool sets in their
99
analysis (e.g. Julia, R, Python) but want to work from a common baseline.
1010
It also has been used intensively for internal reporting from various
1111
Caltech Library metadata sources.
1212

13-
The tools fall into three broad categories
13+
The tools fall into three broad categories
1414

1515
- data transformation and conversion
1616
- shell scripting helpers
1717
- "string", a tool providing the common string operations missing from shell
1818

1919
See [user manual](user-manual.md) for a complete list of the command line
2020
programs. The data transformation tools include support for formats such as
21-
Excel XML, csv, tab delimited files, json, yaml and toml.
21+
Excel XML, csv, tab delimited files, json, yaml, toml and url encoding/decoding.
2222

23-
Compiled versions of the datatools collection are provided for Linux
24-
(amd64), Mac OS X (amd64), Windows 10 (amd64) and Raspbian (ARM7).
23+
Compiled versions of the datatools collection are provided for Linux (aarch64/amd64),
24+
Mac OS X (aarch64/amd64), Windows 10 (aarch64/amd64) and Raspberry Pi OS (aarch64).
2525
See https://github.com/caltechlibrary/datatools/releases.
2626

2727
Use "-help" option for a full list of options for each utility (e.g. `csv2json -help`).
@@ -30,38 +30,37 @@ Data transformation
3030
-------------------
3131

3232
The tooling around transformation includes data conversion. These
33-
include tools that work with CSV, tab delimited, JSON, TOML, YAML
34-
and Excel XML.
33+
include tools that work with CSV, tab delimited, JSON, TOML, YAML,
34+
Excel XML, and url encoded text.
3535

3636
There is also tooling to change data shapes using JSON as the
3737
intermediate data format.
3838

3939
For the shell
4040
-------------
4141

42-
Various utilities for simplifying work on the command line.
42+
Various utilities for simplifying work on the command line.
4343

44-
+ [findfile](docs/findfile/) - find files based on prefix, suffix or contained string
45-
+ [finddir](docs/finddir/) - find directories based on prefix, suffix or contained string
46-
+ [mergepath](docs/mergepath/) - prefix, append, clip path variables
47-
+ [range](docs/range/) - emit a range of integers (useful for numbered loops in Bash)
48-
+ [reldate](docs/reldate/) - display a relative date in YYYY-MM-DD format
49-
+ [reltime](docs/reltime/) - display a relative time in 24 hour notation, HH:MM:SS format
50-
+ [timefmt](docs/timefmt/) - format a time value based on Golang's time format language
51-
+ [urlparse](docs/urlparse/) - split a URL into parts
44+
- [mergepath](docs/mergepath/) - prefix, append, clip path variables
45+
- [reldocpath](reldocpath.1.md) - calculates relative paths given do paths
46+
- [range](docs/range/) - emit a range of integers (useful for numbered loops in Bash)
47+
- [reldate](docs/reldate/) - display a relative date in YYYY-MM-DD format
48+
- [reltime](docs/reltime/) - display a relative time in 24 hour notation, HH:MM:SS format
49+
- [timefmt](docs/timefmt/) - format a time value based on Golang's time format language
50+
- [urlparse](docs/urlparse/) - split a URL into parts
5251

5352
For strings
5453
-----------
5554

56-
_datatools_ provides the [string](docs/string/) command for working with
57-
text strings (limited to memory available). This is commonly needed when
58-
cleanup data for analysis. The _string_ command was created for when the
59-
old Unix standbys- grep, awk, sed, tr are unwieldly or inconvient.
60-
_string_ provides operations are common in most language like, trimming,
61-
spliting, and transforming letter case. The _string_ command also makes
62-
it easy to join JSON string arrays into single a string using a delimiter
63-
or split a string into a JSON array based on a delimiter. The form of the
64-
command is `string [OPTIONS] [ACTION] [ARCTION_PARAMETERS...]`
55+
_datatools_ provides the [string](docs/string/) command for working with
56+
text strings (limited to memory available). This is commonly needed when
57+
cleanup data for analysis. The _string_ command was created for when the
58+
old Unix standbys- grep, awk, sed, tr are unwieldy or inconvenient.
59+
_string_ provides operations are common in most language like, trimming,
60+
splitting, and transforming letter case. The _string_ command also makes
61+
it easy to join JSON string arrays into single a string using a delimiter
62+
or split a string into a JSON array based on a delimiter. The form of the
63+
command is `string [OPTIONS] [ACTION] [ACTION_PARAMETERS...]`
6564

6665
```shell
6766
string toupper "one two three"
@@ -82,6 +81,5 @@ See [string](docs/string/) for full details
8281
Installation
8382
------------
8483

85-
See [INSTALL.md](install.html) for details for installing pre-compiled
84+
See [INSTALL.md](https://caltechlibrary.github.io/datatools/INSTALL.html) for details for installing pre-compiled
8685
versions of the programs.
87-

about.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</nav>
2626
<section>
2727
<h1 id="about-this-software">About this software</h1>
28-
<h2 id="datatools-1.3.4">datatools 1.3.4</h2>
28+
<h2 id="datatools-1.3.5">datatools 1.3.5</h2>
2929
<h3 id="authors">Authors</h3>
3030
<ul>
3131
<li>R. S. Doiel</li>
@@ -35,7 +35,9 @@ <h3 id="maintainers">Maintainers</h3>
3535
<li>R. S. Doiel</li>
3636
</ul>
3737
<p>A set of command line tools for working with CSV, Excel Workbooks,
38-
JSON and structured text documents.</p>
38+
JSON and structured text documents. Included are tools for handling
39+
urlencoding and urldecoding as well as path relationships on the file
40+
system and in URLs</p>
3941
<ul>
4042
<li>License: <a href="https://data.caltech.edu/license"
4143
class="uri">https://data.caltech.edu/license</a></li>
@@ -46,7 +48,7 @@ <h3 id="maintainers">Maintainers</h3>
4648
</ul>
4749
<h3 id="programming-languages">Programming languages</h3>
4850
<ul>
49-
<li>Go &gt;= 1.23.5</li>
51+
<li>Go &gt;= 1.25.6</li>
5052
</ul>
5153
<h3 id="operating-systems">Operating Systems</h3>
5254
<ul>
@@ -56,7 +58,7 @@ <h3 id="operating-systems">Operating Systems</h3>
5658
</ul>
5759
<h3 id="software-requiremets">Software Requiremets</h3>
5860
<ul>
59-
<li>Golang &gt;= 1.23.5</li>
61+
<li>Golang &gt;= 1.25.6</li>
6062
<li>Pandoc &gt;= 3.1</li>
6163
</ul>
6264
</section>

about.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@ message: "If you use this software, please cite it as below."
44
type: software
55
title: "datatools"
66
abstract: "A set of command line tools for working with CSV, Excel
7-
Workbooks, JSON and structured text documents."
7+
Workbooks, JSON and structured text documents. Included are tools for
8+
handling urlencoding and urldecoding as well as path relationships on
9+
the file system and in URLs"
810
authors:
911
- family-names: Doiel
1012
given-names: R. S.
1113
orcid: ""
1214

1315
repository-code: "https://github.com/caltechlibrary/datatools"
14-
version: 1.3.4
16+
version: 1.3.5
1517
license-url: "https://data.caltech.edu/license"
16-
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash" ]
17-
date-released: 2025-05-15
18+
keywords: [ "csv", "excel", "sql", "json", "yaml", "xlsx", "golang", "bash", "url", "urlencoding" ]
19+
date-released: 2026-02-12
1820
---
1921

2022
About this software
2123
===================
2224

23-
## datatools 1.3.4
25+
## datatools 1.3.5
2426

2527
### Authors
2628

@@ -32,7 +34,9 @@ About this software
3234
- R. S. Doiel
3335

3436
A set of command line tools for working with CSV, Excel Workbooks, JSON
35-
and structured text documents.
37+
and structured text documents. Included are tools for handling
38+
urlencoding and urldecoding as well as path relationships on the file
39+
system and in URLs
3640

3741
- License: <https://data.caltech.edu/license>
3842
- GitHub: <https://github.com/caltechlibrary/datatools>
@@ -41,7 +45,7 @@ and structured text documents.
4145

4246
### Programming languages
4347

44-
- Go &gt;= 1.23.5
48+
- Go &gt;= 1.25.6
4549

4650
### Operating Systems
4751

@@ -51,5 +55,5 @@ and structured text documents.
5155

5256
### Software Requiremets
5357

54-
- Golang &gt;= 1.23.5
58+
- Golang &gt;= 1.25.6
5559
- Pandoc &gt;= 3.1

cmd/reldocpath/reldocpath.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
//
2+
// reldocpath.go takes a source document path and a target document path with same base path
3+
// returning a relative path to the target file.
4+
//
5+
// @author R. S. Doiel, <rsdoiel@caltech.edu>
6+
//
7+
// Copyright (c) 2021, Caltech
8+
// All rights not granted herein are expressly reserved by Caltech.
9+
//
10+
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
11+
//
12+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
13+
//
14+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15+
//
16+
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19+
//
20+
package main
21+
22+
import (
23+
"flag"
24+
"fmt"
25+
"os"
26+
"path"
27+
28+
// My packages
29+
"github.com/caltechlibrary/datatools"
30+
)
31+
32+
var (
33+
helpText = `%{app_name}(1) user manual | version {version} {release_hash}
34+
% R. S. Doiel
35+
% {release_date}
36+
37+
# NAME
38+
39+
{app_name}
40+
41+
# SYNOPSIS
42+
43+
{app_name} [OPTIONS] [STRING]
44+
45+
# DESCRIPTION
46+
47+
Given a source document path, a target document path calculate and
48+
the implied common base path calculate the relative path for target.
49+
50+
# EXAMPLE
51+
52+
Given
53+
54+
reldocpath chapter-01/lesson-03.html css/site.css
55+
56+
would output
57+
58+
../css/site.css
59+
60+
`
61+
62+
// Standard options
63+
showHelp bool
64+
showVersion bool
65+
showLicense bool
66+
showExamples bool
67+
)
68+
69+
func main() {
70+
appName := path.Base(os.Args[0])
71+
version := datatools.Version
72+
license := datatools.LicenseText
73+
releaseDate := datatools.ReleaseDate
74+
releaseHash := datatools.ReleaseHash
75+
76+
// Standard Options
77+
flag.BoolVar(&showHelp, "help", showHelp, "display help")
78+
flag.BoolVar(&showLicense, "license", showLicense, "display license")
79+
flag.BoolVar(&showVersion, "version", showVersion, "display version")
80+
81+
// Parse environment and options
82+
flag.Parse()
83+
args := flag.Args()
84+
85+
//in := os.Stdin
86+
out := os.Stdout
87+
eout := os.Stderr
88+
89+
// Handle the default options
90+
if showHelp {
91+
fmt.Fprintf(out, "%s\n", datatools.FmtHelp(helpText, appName, version, releaseDate, releaseHash))
92+
os.Exit(0)
93+
}
94+
if showLicense == true {
95+
fmt.Fprintf(out, "%s\n", license)
96+
os.Exit(0)
97+
}
98+
if showVersion == true {
99+
fmt.Fprintf(out, "datatools, %s %s %s\n", appName, version, releaseHash)
100+
os.Exit(0)
101+
}
102+
103+
if len(args) != 2 {
104+
fmt.Fprintf(eout, "Expected a source and target file path\n For help try: %s -help", appName)
105+
os.Exit(1)
106+
}
107+
source, target := args[0], args[1]
108+
fmt.Fprintf(out, `%s`, datatools.RelativeDocPath(source, target))
109+
}

0 commit comments

Comments
 (0)