-2

I have a CSV file, for example data may come in ;0; or ;.2; or ;.23456; the output string (to a file) must in this case be 6 bytes with an Implicit decimal, so 0 would of course be 000000, .2 would be 020000, .23456 would be 023456. and 1 would be 100000. There is no guarantee of a decimal, ie: 0 or 1, versus .23456 or 1.23456)

I was trying things like 01.5d, but the decimal or lack thereof in the input field trips me up. I've spent some time reading and looking at coding examples but haven't found anything that addresses this. I'm sure there is a simple but elequoent example some of the experts out there could educate me, or point me to a manual that would guide me.

Thanks.

  • 2
    Please add sample input and your desired output for that sample input to your question. – Cyrus May 04 '18 at 20:10

1 Answers1

0

I guess that's what you're trying to do, but not sure since lacking validation tests

$ awk '{printf "%06d\n", 100000*$1}' <(echo -e ".0\n0\n.23456\n1.23456\n.0123456789")

000000
000000
023456
123456
001234
karakfa
  • 66,216
  • 7
  • 41
  • 56