# Detect Invalid Data by C shell

**URL:** <https://community.unix.com/t/detect-invalid-data-by-c-shell/267703>\
**Category:** Solaris\
**Created:** [June 15, 2010, 11:56am UTC](https://community.unix.com/t/detect-invalid-data-by-c-shell/267703 "2010-06-15T11:56:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elph](https://community.unix.com/letter_avatar/elph/32/6_449c533f586939b6e5f246632a46421f.png) [@elph](https://community.unix.com/u/elph)\
**Post date:** [June 15, 2010, 11:56am UTC](https://community.unix.com/t/detect-invalid-data-by-c-shell/267703/1 "2010-06-15T11:56:07Z")

</div>

Dear all,

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.

Thanks,

---

<div class="post-metadata">

**Author:** ![busyboy](https://community.unix.com/letter_avatar/busyboy/32/6_449c533f586939b6e5f246632a46421f.png) [@busyboy](https://community.unix.com/u/busyboy)\
**Post date:** [June 21, 2010, 3:14am UTC](https://community.unix.com/t/detect-invalid-data-by-c-shell/267703/2 "2010-06-21T03:14:36Z")

</div>

Can you please try putting some data here to see what can be customized.  
thanks

---

<div class="post-metadata">

**Author:** ![elph](https://community.unix.com/letter_avatar/elph/32/6_449c533f586939b6e5f246632a46421f.png) [@elph](https://community.unix.com/u/elph)\
**Post date:** [June 23, 2010, 12:02pm UTC](https://community.unix.com/t/detect-invalid-data-by-c-shell/267703/3 "2010-06-23T12:02:51Z")

</div>

Hi busyboy,Thanks for your advice.

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.
