Compare commits

..

9 Commits

Author SHA1 Message Date
olli
cb67db2a78 added headers 2024-10-22 10:55:58 +02:00
olli
71cf1ec44c change expionential numbers in normal notation in given file 2024-10-21 10:39:34 +02:00
olli
ed19ae5c0d too many arguments 2024-09-21 20:02:46 +02:00
olli
c4d9e053ee ignore VirtualBox 2024-09-08 17:43:19 +02:00
olli
8d88743624 super array v/vr 2024-08-24 13:16:37 +02:00
olli
2cdab60efb super array v/vr 2024-08-24 12:58:12 +02:00
olli
c761fe5d93 calc median g_ 2024-08-16 23:35:21 +02:00
olli
4342f0a5f8 calc median g_ 2024-08-16 23:27:37 +02:00
olli
be7e5da172 calc median g_ 2024-08-16 23:17:33 +02:00
7 changed files with 42 additions and 16 deletions

View File

@@ -72,6 +72,7 @@ vpn
.config/Nextcloud/
nextcloud-test.*/
.VirtualBox/
VirtualBox/
DMS/
tmp
.zoom/

View File

@@ -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:-/}
}

View File

@@ -27,7 +27,7 @@ function g_calc {
read -u ${g_fd_bc_out} g_calc_result
# check if there is a output
if [ -z $g_calc_result ]
if [ -z "$g_calc_result" ]
then
echo "${FUNCNAME} $@" 1>&2
unset g_calc_result
@@ -48,7 +48,7 @@ function g_calc {
[[ $g_calc_result == *"." ]] && g_calc_result=${g_calc_result%?}
# check output
if ! g_num_valid_number $g_calc_result
if ! g_num_valid_number "$g_calc_result"
then
echo "${FUNCNAME} $@" 1>&2
unset g_calc_result

View File

@@ -11,20 +11,16 @@ function g_median {
local g_num_elements=${#g_sorted_numbers[@]}
# calculate the middle
local g_middle=$((g_num_elements/2))
local g_middle=$(($g_num_elements/2))
local g_median
# even/odd number
if ((g_num_elements % 2 == 1))
if (($g_num_elements % 2 == 1))
then
# odd number
echo "g_middle=$g_middle"
g_median=${g_sorted_numbers[g_middle]}
g_median_result="${g_sorted_numbers[$g_middle]}"
else
# even number
g_calc "(${g_sorted_numbers[g_middle - 1]} + ${g_sorted_numbers[g_middle]}) / 2"
g_median=$g_calc_result
g_calc "(${g_sorted_numbers[$g_middle - 1]} + ${g_sorted_numbers[$g_middle]}) / 2"
g_median_result="$g_calc_result"
fi
g_median_result=$g_median
}

View File

@@ -0,0 +1,11 @@
function g_num_exponential2normal_file {
# changes expionential numbers in normal notation in given file
local g_file=$1
local g_substitution g_exnum
for g_exnum in $(egrep -o -i "[0-9]+\.[0-9]+e[\+\-][0-9]+" "$g_file" | sort -u)
do
g_num_exponential2normal $g_exnum && g_substitution="${g_substitution}s/${g_exnum}/${g_num_exponential2normal_result}/g;"
done
sed -i "${g_substitution}" "$g_file" && return 0
}

View File

@@ -48,6 +48,11 @@ 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_]/}
g_csvfile_base=${g_csvfile_base//ECONOMY*/}
# read last lines if defined or complete csv file
if [ -n "$g_last_lines" ]
then
@@ -55,14 +60,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 +82,14 @@ 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]}"
if [ -z "${g_csvfile_base}" ]
then
v[${g_headline_item}_${r}]=${g_csv_line_array[i]}
vr[${g_headline_item}_${l}]=${g_csv_line_array[i]}
else
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]}
fi
((i++))
done
((l++))

View File

@@ -1,3 +1,7 @@
function g_wget {
wget -T 10 -t 2 -U "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36" $@
wget -T 10 -t 2 \
--header="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" \
--header="Content-Type: application/json" \
--header="Accept-Language: en-US,en," \
$@
}