I'd be so grateful if I could get great feedback again for my problems.
We usually spool some text files from our system in csv format.
Unfortunately, some data contains ',' (comma) and it's rare case but when it comes to spool, that row included comma should be invalid data, due to extra comma, as you can imagine.
We can't prevent to be input comma, due to strong users' request, so we decided to enclose " (double-quotation) each fields in further development.
I'm just wondering if we can check the comma counts of each current spool files and detect the invalid data included or not.
If you would have any good command or shell to work on this, pls advise me.
Let me try to give you simple sample for what we'd like to do.
In case we have 4 columns from A to D, the delimitar should be 3.
But if B columns contains comma like 3rd row, this comma should be judged as delimitar, not usual character in csv format. We'd like to detect the invalid row with extra delimitar compaired to the other rows.
FieldA | FieldB|FieldC|FieldD
---------------------------
AAA,BBB,CCC,DDD
AA,BB,CC,DDD
AAA,BB,B,CCCC,DDDD -- NG ROW
We'd like to detect third row as invalid row with extra delimitar.
I'm wondering if we can use awk command to detect extra delimitar but so far I'm out of resources.
I'd be grateful if you could give me any little advice.
Thank you.