super array v/vr
This commit is contained in:
parent
c761fe5d93
commit
2cdab60efb
@ -1,5 +1,5 @@
|
||||
function g_basename {
|
||||
g_basename_result="${1##*/}"
|
||||
g_basename_result="${g_basename_result:-/}"
|
||||
g_basename_result=${1##*/}
|
||||
g_basename_result=${g_basename_result:-/}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,10 @@ function g_read_csv {
|
||||
g_csv_headline_array+=("${g_headline_item//[^a-zA-Z0-9_]/}")
|
||||
done
|
||||
|
||||
g_basename $g_csvfile
|
||||
local g_csvfile_base=${g_basename_result/\.history*.csv/}
|
||||
g_csvfile_base=${g_csvfile_base//[^a-zA-Z0-9_]/}
|
||||
|
||||
# read last lines if defined or complete csv file
|
||||
if [ -n "$g_last_lines" ]
|
||||
then
|
||||
@ -55,14 +59,15 @@ function g_read_csv {
|
||||
g_csvfile="${g_tmp}/g_csv_tmp.csv"
|
||||
fi
|
||||
|
||||
|
||||
# read csv file to array
|
||||
g_array "$g_csvfile" g_csv_array_ref
|
||||
g_csv_array=("${g_csv_array_ref[@]}")
|
||||
|
||||
# go reverse through array
|
||||
# create associative arrays forward and reverse and superarray v/vr
|
||||
declare -Ag v_csv_array_associative
|
||||
declare -Ag v_csv_array_associative_reverse
|
||||
declare -Ag v
|
||||
declare -Ag vr
|
||||
l=0
|
||||
for (( r=${#g_csv_array[@]}-1 ; r>=0 ; r-- ))
|
||||
do
|
||||
@ -76,6 +81,8 @@ function g_read_csv {
|
||||
[ "$l" = 0 ] && declare -g v_${g_headline_item}="${g_csv_line_array[i]}"
|
||||
v_csv_array_associative[${g_headline_item}_${r}]="${g_csv_line_array[i]}"
|
||||
v_csv_array_associative_reverse[${g_headline_item}_${l}]="${g_csv_line_array[i]}"
|
||||
v[${g_csvfile_base}_${g_headline_item}_${r}]=${g_csv_line_array[i]}
|
||||
vr[${g_csvfile_base}_${g_headline_item}_${l}]=${g_csv_line_array[i]}
|
||||
((i++))
|
||||
done
|
||||
((l++))
|
||||
|
Loading…
Reference in New Issue
Block a user