Untitled

mail@pastecode.io avatar
unknown
powershell
2 years ago
1.1 kB
3
Indexable
#! /bin/bash 
csv_file="fake_tokens.csv"
arr_csv=() 
while IFS= read -r line 
do
      # Skip the header row
  if [[ $header_skipped != 1 ]]; then
    header_skipped=1
    continue
  fi
    arr_csv+=("$line")
done < "$csv_file"

len=${#arr_csv[@]}
number_of_calls=2

slice_size=$((len / number_of_calls))

echo $slice_size


batch1=(${arr_csv[@]:0:slice_size})
batch2=(${arr_csv[@]:slice_size})

echo "Displaying the contents of array mapped from csv file:"
index=0
for record in "${arr_csv[@]}"
do
    echo "Record at index-${index} : $record"
	((index++))
done

echo "Displaying the contents of batch1:"
index=0
for record in "${batch1[@]}"
do
    echo "Record at index-${index} : $record"
	((index++))
done

echo "Displaying the contents of batch2:"
index=0
for record in "${batch2[@]}"
do
    echo "Record at index-${index} : $record"
	((index++))
done


#this should expand the array records and display the results
#chodzi mi o to tutaj, chcialbym zeby mi to wyswietlilo np. [element1, element2, itd.] a wyswietla tylko jedna wartosc
echo "${batch1[*]}"