Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Ian Dennis Miller
dataset-guide
Commits
56aceb54
Commit
56aceb54
authored
Sep 30, 2018
by
Ian Dennis Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update csv-functions.sh
parent
74faa4fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
csv-functions.sh
csv-functions.sh
+9
-2
No files found.
csv-functions.sh
View file @
56aceb54
...
...
@@ -3,6 +3,10 @@
# Perform streaming operations with CSV files.
# When files are too large to fit into memory, streaming might be the only alternative.
PROFILE
=
"
$HOME
/.profile"
CSV_SRC
=
"
$HOME
/.csv-functions.sh"
CSV_URL
=
'https://projects.sisrlab.com/idm/dataset-guide/raw/master/csv-functions.sh?inline=false'
# collapse fields containing newlines
alias
csv.collapse
=
'perl -pe "s/\\\\\n/ /" -'
...
...
@@ -33,8 +37,11 @@ csv.count() { wc -l - | awk '{ print $1 }' }
# cat a CSV file
csv.cat
()
{
cat
$1
| csv.collapse
}
# print column names, each on a separate line
#
For a CSV with a header row,
print column names, each on a separate line
csv.names
()
{
csv.cat
$1
| csv.limit 1 | csv.unquote | csv.split
}
# built-in updater
csv.update
()
{
wget
-O
~/.csv-functions.sh
'https://projects.sisrlab.com/idm/dataset-guide/raw/master/csv-functions.sh?inline=false'
;
source
~/.csv-functions.sh
}
csv.update
()
{
wget
-O
$CSV_SRC
$CSV_URL
;
source
$CSV_SRC
}
# make installation permanent
csv.install
()
{
if
[[
-z
`
grep
csv-functions.sh
$PROFILE
`
]]
;
then
echo
"source
$CSV_SRC
"
>>
$PROFILE
;
fi
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment