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
74faa4fe
Commit
74faa4fe
authored
Sep 30, 2018
by
Ian Dennis Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update csv-functions.sh
parent
12343ebb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
csv-functions.sh
csv-functions.sh
+4
-1
No files found.
csv-functions.sh
View file @
74faa4fe
...
...
@@ -12,8 +12,11 @@ alias csv.unquote='sed "s/\"//g"'
# split a comma-delimited row onto separate lines
alias
csv.split
=
'sed -e "s/,/\\n/g"'
# produce awk expression suitable for selecting the requested columns
csv.awk_select_column
()
{
awk
'BEGIN {for (i=1; i < ARGC; i++) printf "$" ARGV[i] ", "}'
$@
| rev |
cut
-c
3- | rev
}
# select a single column from a CSV by its index, starting at 1
csv.select_column
()
{
awk
-F
,
"
{print
\$
$1
}"
}
csv.select_column
()
{
awk
-F
,
"
BEGIN{OFS =
\"
,
\"
} { print
`
csv.awk_select_column
$@
`
}"
}
# limit number of rows returned
csv.limit
()
{
head
-n
$1
}
...
...
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