Hello,
I have a csv file which has a few fields that have quoted dynamic entries. I used the csv module to break out the fields and now I am trying to account for the embedded subfields. There are two different scenarios:
#1 The first integer in the subfield defines how many times the remaining subfieds will repeat
Example:
"MSD" => "1,X,Y,Z"
or
"MSD" => "2,X1,Y1,Z1,X2,Y2,Z2"
Desired output:
"MSD" => {
"NS" => 1,
"INPUT_1" => X1,
"OUTPUT_1" => Y1,
"MEASURE_1" => Z1,
}
"MSD" => {
"NS" => 2,
"INPUT_1" => X1,
"OUTPUT_1" => Y1,
"MEASURE_1" => Z1,
"INPUT_2" => X2,
"OUTPUT_2" => Y2,
"MEASURE_2" => Z2
}
#2 The First Field provides the total number of remaining fields.
Example:
"RD" => "3,A,B,C"
or
"RD" => "4,A,B,C,D"
Desired output: (All fields will have specific names, I know there is a maximum of 20)
"RD" => {
"count" => "x"
"Static_field"=>A
...
"Another_Statically_named_fieldX => "x"
}
Thanks for any push in the right direction.