I'm trying to do the following for a while but without success.The data I received has comma separated values in each separate columns. The first value in column 6 before the comma is always related to the first value in column 7 before the comma. I want to extract data and put them into a table in the right order as such:Input Data:1 2 3 4 5 A1,A2 B1,B21 7 3 3 5 C1,C2,C3 D1,D2,D31 2 R 4 b E1,E2,E3,E4 G1,G2,G3,G4Output Data:1 2 3 4 5 A1 B11 2 3 4 5 A2 B21 7 3 3 5 C1 D1 1 7 3 3 5 C2 D21 7 3 3 5 C3 D31 2 R 4 b E1 G11 2 R 4 b E2 G21 2 R 4 b E3 G31 2 R 4 b E4 G4I understand I need to split them by \t before placing them into an array of sort, but I'm utterly new to this and having received such huge data.
Processing table with comma separated values in different columns
command line;text processing;csv
With awk:awk '{split($6,a,,); split($7,b,,); for(i in a){print $1,$2,$3,$4,$5,a[i],b[i]}}' fileawk reads the input space or tab delimited, default: [\t ]+.split($6,a,,) split the 6th field $6 separated by comma , and store the output in an array called a.split($7,b,,) split the 7th field $7 separated by comma , and store the output in an array called b.for(i in a) now loop trough the a array...print ...,a[i],b[i] ... and print the values $1 to $5 and the two array values a[i] and b[i] by their indexes i.The output:1 2 3 4 5 A1 B11 2 3 4 5 A2 B21 7 3 3 5 C1 D11 7 3 3 5 C2 D21 7 3 3 5 C3 D31 2 R 4 b E1 G11 2 R 4 b E2 G21 2 R 4 b E3 G31 2 R 4 b E4 G4