Clutch

TablePrint to structure your data

TablePrint to structure your data
Average rating: 0
(0 votes)

If you invest the time earlier to create structure and process around communication, planning, and goal-setting, you can prevent missteps before they occur. The same thing happens with the data structure. And we have a solution on how to make your life easier! You can use TablePrint to structure your data.

Let’s start! TablePrint was created to show objects in formatted columns for easy reading. It lets you nest other tables of related objects, contextualizing data across tables. It’s very flexible, simple, making it easy to see the data you care about.

TablePrint tries to use sensible defaults to choose the columns to show. If you’re inspecting ActiveRecord objects, it uses the ActiveRecord column names. You can customize the output to show fewer columns or show other methods you’ve written on your model. Use symbols or strings to reference the columns.

Here are available column options that you can use:

  • display_method – string/symbol/proc – used to populate the column. Can be a method name.
  • formatters – array of objects – each will be called in turn as the cells are printed.
  • time_format – string – passed to strftime, only affects time columns.
  • width – integer – how wide you want your column.
  • display_name – string – use it if you want spaces in your column name.
  • separator – string – default is a vertical bar for console and markdown, change it to a comma for CSV output.

Feel free to find more examples here.

By the way, did you see our recent article about using Groupdate to group temporal data in Active Record? Oh, it’s worth reading.

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

*By submitting this form you agree with our Privacy Policy.

Mailing & Legal Address

Syndicode Inc. 340 S Lemon Ave #3299, Walnut CA, 91789, USA

Visiting & Headquarters address
Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
Email info@syndicode.com
Phone (+1) 9035021111