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
|
||||
|
||||
USAGE
|
||||
$scriptname [-b before] -e script [-a after] [headers...]
|
||||
$scriptname [-b before] -e script [-a after] [headers...] [-- inputfiles...]
|
||||
|
||||
$__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
|
||||
|
||||
USAGE
|
||||
$scriptname [header:sizes...]
|
||||
$scriptname [header:sizes...] [-- inputfiles...]
|
||||
|
||||
$__AWKFSV2CSV_HELP"
|
||||
|
||||
|
|
19
ulib/awk
19
ulib/awk
|
@ -690,8 +690,15 @@ function lawkcsv() {
|
|||
qchar="${qchar: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
|
||||
|
||||
if [ -n "$fieldmap" ]; then
|
||||
awkscript="$awkscript"'{
|
||||
if (do_once("mapfields")) { mapfields(fields2map) }
|
||||
|
@ -746,7 +753,7 @@ $awkscript
|
|||
$append_awkscript
|
||||
$afterscript
|
||||
$append_afterscript
|
||||
"
|
||||
" -- "$@"
|
||||
}
|
||||
|
||||
function cawkcsv() { LANG=C lawkcsv "$@"; }
|
||||
|
@ -785,7 +792,10 @@ function lawkfsv2csv() {
|
|||
local -a headers starts sizes
|
||||
local headersize header i size
|
||||
i=1
|
||||
for headersize in "$@"; do
|
||||
while [ $# -gt 0 -a "$1" != "--" ]; do
|
||||
headersize="$1"
|
||||
shift
|
||||
|
||||
splitpair "$headersize" header size
|
||||
[ -n "$header" ] || {
|
||||
eerror "header est requis"
|
||||
|
@ -799,6 +809,7 @@ function lawkfsv2csv() {
|
|||
fi
|
||||
i="$(($i + $size))"
|
||||
done
|
||||
shift
|
||||
|
||||
awkrun -f \
|
||||
skip_lines:int="$skip_lines" show_headers:int="$show_headers" \
|
||||
|
@ -819,7 +830,7 @@ NR <= skip_lines { next }
|
|||
formatcsv()
|
||||
print
|
||||
}
|
||||
'
|
||||
' -- "$@"
|
||||
}
|
||||
|
||||
function cawkfsv2csv() { LANG=C lawkfsv2csv "$@"; }
|
||||
|
|
Loading…
Reference in New Issue