O'Reilly logo

Text Processing with Ruby by Rob Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing a TSV

Let’s imagine we have a spreadsheet that represents our personal expenditures. We want to keep track of what we buy, how much it costs, and where we bought it. So we set up a spreadsheet in which each row (or record) represents a purchase, and in which the columns (or fields) represent the item name, the price, and the retailer from which it was bought.

We happily record our data, and all is well. But the list soon becomes unwieldy, and it’s difficult to analyze the data. We might want to find out our most expensive ever item, for example, or calculate the average cost of an item from a particular retailer. If we get the data into Ruby, these calculations will be straightforward, so let’s find out how to do that.

Our first step ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required