I have a csv file which has multiple columns. Here is an example of what i'm stuck with. Below is sample input data:
9,-54,18205,28,0,1517400128,2353,0,0,0,0,551
9,-54,18207,28,0,1517400128,2354,0,0,0,0,551
10,-48,18216,28,0,1517400128,2353,0,0,0,0,551
9,-54,18217,28,0,1517400128,2356,0,0,0,0,551
13,-54,18223,28,0,1517400128,2353,0,0,0,0,551
I want to split the data based on unique values from column 1, and then further split the resultants based on unique value from column 7. Currently i'm trying to achieve this by first splitting the sheet based on column 1, then i'm reading the resultant csv files from the directory, storing it in an output txt file and then further taking the values from output txt file as variables and running an awk script to split the files further. But somehow the 2nd split is not happening as per expectation. Below is what i have done so far:
awk -F\, '{print > $7".csv"}' $dir/../testfile.csv
ls -R | grep "\.csv$" > testfile.txt
while IFS= read -r a \n b \n c; do
awk -F\, '{print > $1".csv"}' $dir/$a
awk -F\, '{print > $1".csv"}' $dir/$b
awk -F\, '{print > $1".csv"}' $dir/$c
done < testfile.txt
Please help me identify the issue here. This has to be in shell.