I want to parse a csv file in zsh row by row and store it in an array (without the commas). Is it possible to import a single row into an array in zsh, then afterwards grab the next row?
The issue is I am using a large csv file and cannot import it all quickly. I tried using the code below:
arr_csv=()
while IFS= read -r line
do
arr_csv+=("$line")
done < import.csv
but since the file is large, I want to read and store a single line (or access a single line).
I understand I could modify the code such that
arr_csv=()
while IFS= read -r line
do
arr_csv=("$line")
# some modifications
done < import.csv
but if I wanted to loop over the file it would be easier if I could use an index corresponding to the row from the csv file. Also, this method does not remove the commas separating the rows.
csvkit
,miller
,awk
,python
,perl
, etc.) – Chris Davies Jul 11 '22 at 21:09