0

How to remove the null from csv file. 2015|||89019||2731||14.5|6.5|11.0|10.8|17.6|18.6|20.9|41.4|43.6||6.0|8.9|33.9|26.6|3.6|14.4|||6.6||55.1|20.3|8.0|12.5|1.1|0.3|2.7||56.6|37.4|6.0|9.7||33.3|43.4|3.9|1.8|17.6||32.8|37.0|20.6|0.8|0.0|7.5|1.4||52.1|47.9|1.09||89019|||405|0|0|3|600|436|1444||28.0|0.0|0.0|0.2|41.6|30.2|100.0||1134|310|21.5|46.3|53.7|2.41||20.7|8.5|9.9|17.1|19.3|8.1|9.5|3.4|3.5|59956|46368

As you can see there some null (empty) fields example:2nd and 3rd fields.

How can I remove them.

2 Answers 2

1
awk 'gsub("\\|+","|")' filename

sed 's:||*:|:g' filename
Sign up to request clarification or add additional context in comments.

1 Comment

2015|||89019 ==> ||| ==sub==> |
0
sed 's/|\{2,\}/|/g' YourFile

Replace (s///) any (g) occurrence of at least 2 (\{2,\}\) character | by a single one

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.