I have a CSV file which needs to separate values into separate CSV file.
It already has an existing code:\
-
First sub file needs a file that contains value in first and second fields
egrep "^[^,]+,[^,]+," orig.csv > suba.csv -
Second sub contains files containing values in first but empty in the second
egrep "^[^,]+,," orig.csv > subb.csv
From what I understand the ^[^,]+, means must start with a value but the value must not be a comma then followed by a comma.
We have a new requirement that the fifth column must not be a blank:
Here is what I thought it should be but unfortunately it still receives the value with the fifth column with no value
egrep "^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+" orig.csv > suba_2.csv
Any ideas?
Try:
I am suspecting there is whitespace in your fifth element.
Your regex worked for me with the following input:
But not when I put a space at the end of the last line 1,2,3,4, .