Skip to content
Advertisement

replace numbers smaller than certain threshold with zero

I have a large data sheet (see below) in .csv format. I want to replace the numbers in each column and row with zero if it is smaller than a certain value, let’s say 0.1.

Could anyone give me a hand? Thanks a lot.

I guess it can be done with sed as in this example

JavaScript

Advertisement

Answer

Here is one for GNU awk. Field separator is assumed to be a run of space so empty fields are not allowed:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement