Formatting Output with printf

Until now we’ve been outputting simple strings in a simple way. But if our output is destined to be read by a human being, we’re going to need something a bit better.

Very often, when doing data analysis and reporting, the data we’re producing isn’t for our own benefit. It’s destined for the marketing department, for sales, for executives—most of whom would run a mile rather than view output on the command line.

But outputting to the screen is such a cheap thing to do, in terms of development time, that it’s often the medium of first resort. Debugging information, programs that are used by developers, and many other applications will need to output to the terminal. Learning to make that output readable is a useful ...

Get Text Processing with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.