Free plan

Group and Pivot

Total up a table by groups, like sales per country
POST
/v1/data/aggregate

About this tool

This tool groups the rows of a table by a column and does a sum for each group: count, total, average, smallest or largest. It can also make a pivot table, where the values of one column become the columns of the result. It works with CSV, Excel and other table files.
For example, you have a list of orders and want the total sales for each country.

How to use it

  1. Choose this tool.
  2. Add your table file, such as CSV or Excel.
  3. Type the column to group by, and what to calculate, such as sum:amount.
  4. Choose the format of the result, and sorting or a limit if you want.
  5. Press Generate.

What you get back

You get a new, smaller table with one row per group, to download or copy.
GOOD TO KNOW
One file in, one result table out. Numbers written as text are counted as numbers; empty cells are skipped by every function except count.
TEST IT LIVE

Try Group and Pivot in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Data
Plan
Free
Method
POST
Endpoint
/v1/data/aggregate
Tool ID
data.aggregate
Authentication
API key
Accepts
XLSX, ODS, MD, HTML, XLS, CSV +9 more
Background jobs
Yes
Usage group
Data
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/data/aggregate" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'file=@document.pdf' \
  -F 'group_by=country' \
  -F 'aggregations=sum:amount, count' \
  -F 'pivot=year'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.data.aggregate({
    "file": 'document.pdf',
    "group_by": "country",
    "aggregations": "sum:amount, count",
    "pivot": "year"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->data()->aggregate([
    'file' => 'document.pdf',
    'group_by' => 'country',
    'aggregations' => 'sum:amount, count',
    'pivot' => 'year',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Group the rows of a data file and total each group: count, sum, average, smallest, largest and more. With pivot, the values of one column become the columns of the result, like a pivot table.

Group and Pivot accepts XLSX, ODS, MD, HTML, XLS, CSV, JSON, XML, TSV, NDJSON, YAML, TOML and 3 more. You can send several files in one request.

Group and Pivot is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/data/aggregate with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.