possibilité de spécifier des fichiers pour awkcsv et awkfsv2csv
This commit is contained in:
parent
8655a95d37
commit
be66ada5a6
4
uawk
4
uawk
|
@ -19,7 +19,7 @@ if [ "$scriptname" == "awkcsv" ]; then
|
||||||
note: ce script ne tient pas compte de la locale: il travaille avec LANG=C
|
note: ce script ne tient pas compte de la locale: il travaille avec LANG=C
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
$scriptname [-b before] -e script [-a after] [headers...]
|
$scriptname [-b before] -e script [-a after] [headers...] [-- inputfiles...]
|
||||||
|
|
||||||
$__AWKCSV_HELP"
|
$__AWKCSV_HELP"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ elif [ "$scriptname" == "awkfsv2csv" ]; then
|
||||||
note: ce script ne tient pas compte de la locale: il travaille avec LANG=C
|
note: ce script ne tient pas compte de la locale: il travaille avec LANG=C
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
$scriptname [header:sizes...]
|
$scriptname [header:sizes...] [-- inputfiles...]
|
||||||
|
|
||||||
$__AWKFSV2CSV_HELP"
|
$__AWKFSV2CSV_HELP"
|
||||||
|
|
||||||
|
|
19
ulib/awk
19
ulib/awk
|
@ -690,8 +690,15 @@ function lawkcsv() {
|
||||||
qchar="${qchar:0:1}"
|
qchar="${qchar:0:1}"
|
||||||
echar="${echar:0:1}"
|
echar="${echar:0:1}"
|
||||||
|
|
||||||
[ -n "$*" ] && headers=("$@")
|
headers=()
|
||||||
|
while [ $# -gt 0 -a "$1" != "--" ]; do
|
||||||
|
array_add headers "$1"
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
|
||||||
[ -n "${headers[*]}" ] || parse_headers=1
|
[ -n "${headers[*]}" ] || parse_headers=1
|
||||||
|
|
||||||
if [ -n "$fieldmap" ]; then
|
if [ -n "$fieldmap" ]; then
|
||||||
awkscript="$awkscript"'{
|
awkscript="$awkscript"'{
|
||||||
if (do_once("mapfields")) { mapfields(fields2map) }
|
if (do_once("mapfields")) { mapfields(fields2map) }
|
||||||
|
@ -746,7 +753,7 @@ $awkscript
|
||||||
$append_awkscript
|
$append_awkscript
|
||||||
$afterscript
|
$afterscript
|
||||||
$append_afterscript
|
$append_afterscript
|
||||||
"
|
" -- "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function cawkcsv() { LANG=C lawkcsv "$@"; }
|
function cawkcsv() { LANG=C lawkcsv "$@"; }
|
||||||
|
@ -785,7 +792,10 @@ function lawkfsv2csv() {
|
||||||
local -a headers starts sizes
|
local -a headers starts sizes
|
||||||
local headersize header i size
|
local headersize header i size
|
||||||
i=1
|
i=1
|
||||||
for headersize in "$@"; do
|
while [ $# -gt 0 -a "$1" != "--" ]; do
|
||||||
|
headersize="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
splitpair "$headersize" header size
|
splitpair "$headersize" header size
|
||||||
[ -n "$header" ] || {
|
[ -n "$header" ] || {
|
||||||
eerror "header est requis"
|
eerror "header est requis"
|
||||||
|
@ -799,6 +809,7 @@ function lawkfsv2csv() {
|
||||||
fi
|
fi
|
||||||
i="$(($i + $size))"
|
i="$(($i + $size))"
|
||||||
done
|
done
|
||||||
|
shift
|
||||||
|
|
||||||
awkrun -f \
|
awkrun -f \
|
||||||
skip_lines:int="$skip_lines" show_headers:int="$show_headers" \
|
skip_lines:int="$skip_lines" show_headers:int="$show_headers" \
|
||||||
|
@ -819,7 +830,7 @@ NR <= skip_lines { next }
|
||||||
formatcsv()
|
formatcsv()
|
||||||
print
|
print
|
||||||
}
|
}
|
||||||
'
|
' -- "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function cawkfsv2csv() { LANG=C lawkfsv2csv "$@"; }
|
function cawkfsv2csv() { LANG=C lawkfsv2csv "$@"; }
|
||||||
|
|
Loading…
Reference in New Issue