I'm trying to print specific fields in this CSV file using awk but I'm running into an issue where some of the lines contain commas but they aren't new fields. For example, the following line is no problem for me.
ABAKEV,InChI=1S/C10H7NO/c12-7-9-6-5-8-3-1-2-4-10(8)11-9/h1-7H,8,2,H7C10ON,1562.9152
I use:
awk -F "," '{print $1,$3,$5,$6}'
which gives me my desired result:
ABAKEV 8 H7C10ON 1562.9152
However, when there are some lines which contain commas within brackets that are supposed to belong to the second field. For example:
ACEMID03,InChI=1S/C2H5NO/c1-2(3)4/h1H3,(H2,3,4),18,1,H5C2ON,1491.2031,-,308.5,158.19,CC(=O)N,10.87831,3.89183,54.21
Specifically,
(H2,3,4)
My desired result is:
ACEMID03 18 H5C2ON 1491.2031
Does anyone have any ideas for how I can break this up the way I want to? Preferably I'd like to use awk because I'm more familiar with it. If someone else has any quick solutions, please let me know. Thanks!