As part of some report generation, I've written a script to fetch the values from DB. But, unluckily, for certain Time ranges(1-9.99,10-19.99 etc), I don't have data in DB.
In such cases, I would like to write zero (0) instead of empty. The desired output will be exported to csv file.
Possibility of fixed columns are: DATE:HH:1-9.99,10-19.99,20-29.99,30-39.99,40-49.99,50-59.99,60+
I've a file with below content:
DATE:HH:1-9.99,10-19.99,20-29.99,30-39.99,40-49.99,50-59.99,60+
---------------------------------------------------------------------
2017-07-18 10 1-9.99 1:100%
2017-07-18 11 60+ 3:100%
2017-07-18 12 40-49.99 1:50% 60+ 1:50%
2017-07-18 13 1-9.99 5:12.2% 10-19.99 4:9.76% 20-29.99 2:4.88% 30-39.99 2:4.88% 60+ 28:68.29%
2017-07-18 14 40-49.99 1:14.29% 60+ 6:85.71%
2017-07-18 16 60+ 1:100%
2017-07-18 17 1-9.99 1:7.69% 30-39.99 1:7.69% 60+ 11:84.62%
Desired output is:
DATE:HH:1-9.99,10-19.99,20-29.99,30-39.99,40-49.99,50-59.99,60+
---------------------------------------------------------------------
**2017-07-18 10 1-9.99 1:100% 0 0 0 0 0
2017-07-18 11 0 0 0 0 0 60+ 3:100%
2017-07-18 12 0 0 0 0 40-49.99 1:50% 60+ 1:50%
2017-07-18 13 1-9.99 5:12.2% 10-19.99 4:9.76% 20-29.99 2:4.88% 30-39.99 2:4.88% 0 60+ 28:68.29%
2017-07-18 14 0 0 0 0 40-49.99 1:14.29% 60+ 6:85.71%
2017-07-18 16 0 0 0 0 0 60+ 1:100%
2017-07-18 17 1-9.99 1:7.69% 0 0 30-39.99 1:7.69% 0 60+ 11:84.62%**