I am building a system that is dealing with weights of materials that a company collects. Because of the sheer number of materials collected, the client wishes to have the weights displayed in tonnes (t) and not in kilograms (kg).

However, the data that is entered via an csv contains all of the materials in separate rows, all recorded in KG. I can add all of the KG's together for all the materials to be displayed, but I'm not sure how I can format the value from KG to t.

For example, 10 materials are displayed all weighing 100KG's each. This has a total of 1,000KG, but I want to display it in tonnes which would be either 1t or 1.0t.

Using twig and Symfony2, how can I achieve this?