Skip to main content

CSV ingestion

Comma-separated values (CSV) is a text file format commonly used for data exchange. You can upload CSV files to:

  • Create new datasets.

  • Add new records or overwrite records in an existing dataset.

Ingestion methods

DataHub supports two ingestion methods for CSV.

Ingestion methodSupported file formatsMaximum file size
DataHub APIuncompressed, or ZIP or GZ of a single CSV file30MB
DoiT consoleuncompressed100MB

Be aware of the following:

  • The DataHub API only accepts files no larger than 30MB. If your CSV is beyond 30MB, compress it into a ZIP or GZ archive.

  • The Data Hub API doesn't accept ZIP or GZ archives that contain more than one CSV.

  • When uploading CSV via the console, large files take longer to process.

Schema templates

A schema template tells DataHub how to read your CSV so it can validate the file and turn the rows into events.

Not every source file uses the same columns, so the template you choose needs to match the file you upload. For example, if you download a spend report from the Anthropic console, choose Anthropic and upload the file as downloaded. You do not need to rename columns. If you have a spreadsheet of internal costs, such as month, territory, and cost, choose Default and format the columns as shown in Example CSV. Choose FOCUS when you are uploading a FOCUS billing export.

You must choose a template when creating a dataset. Default is selected unless you choose another. The template applies to every CSV you upload to that dataset. To use a different template, create a new dataset.

TemplateDescription
DefaultDataHub events with dimensions, labels, and metrics. See Syntax and conventions.
FOCUSFinOps Open Cost and Usage Specification (FOCUS) data.
AnthropicAnthropic spend report CSV uploaded directly from the Anthropic console. See Anthropic spend report.

Syntax and conventions

The following syntax and conventions apply to CSV files uploaded with the Default schema template.

  • Separate values with commas.

  • Add each data record as a new line, using Carriage Return and Line Feed (CRLF) as the line break.

  • The first line is a header row.

Header row syntax: usage_date[,id],DIMENSION_KEY...,METRICS_TYPE...

  • Field names in the header row must use the correct format; DataHub doesn't modify the field names.

  • usage_date: The timestamp (RFC3339) of the data record, corresponding to the time property in the DataHub Events schema.

    • The CSV file must not contain records with timestamps (usage_date) older than two years.
    • The timestamps must strictly follow a subset of RFC 3339/ISO 8601 UTC format: YYYY-MM-DDTHH:MM:SSZ with the uppercase Z. For example, 2025-07-23T18:24:34Z. This restriction eliminates timezone ambiguity and simplifies validation.
  • id: The unique identifier of the record, corresponding to the id property in the DataHub Events schema.

    • If you prefer the UUIDv4 identifier automatically generated at ingestion time, do not include this property in your CSV.
    • To overwrite an existing record in a dataset, make sure to include the correct id in your CSV.
  • DIMENSION_KEY: The keys of dimensions in your dataset. At least one dimension key must be present.

    • For fixed dimensions, see Allowed keys for fixed dimensions.
      • Fixed dimensions must be prefixed with fixed, for example, fixed.billing_account_id, fixed.sku_description.
      • Fixed dimensions are case insensitive.
      • A primary use case for fixed dimensions is joining business and cloud billing datasets for unit economics analysis.
    • For label dimensions, use the format label.CUSTOM_DIMENSION_KEY. For example, label.foo. Label dimensions are case sensitive.
    • For project_label dimensions, use the format project_label.DIMENSION_KEY. For example, project_label.app. Project_label dimensions are case sensitive.
    • For system_label dimensions, use the format system_label.DIMENSION_KEY. For example, system_label.app. System_label dimensions are case sensitive.
  • METRICS_TYPE: The types of metrics in your dataset. At least one metric type must be present.

    • Use the format metric.METRICS_TYPE. For example, metric.cost, metric.usage, metric.savings, or metric.custom_metric.
    • Basic metrics (metric.cost, metric.usage, and metric.savings) are case insensitive, all other metric types are case sensitive.
  • Fields in the header row can be arranged in any order. The order is preserved when you preview the ingested CSV.

Warning

Make sure to sanitize your data, for example, mask personally identifiable information (PII), before sending it to DoiT.

Example CSV

Below is a simple example CSV:

Month,Territory,Cost
2024-03-01,AMER,$70000
2024-04-01,AMER,$70000
2024-05-01,AMER,$70000
2024-03-01,EMEA,$7500
2024-04-01,EMEA,$7500
2024-05-01,EMEA,$7500
2024-03-01,APAC,$3700
2024-04-01,APAC,$3700
2024-05-01,APAC,$3700

You can also download a sample CSV with more columns.

Anthropic spend report

If your dataset uses the Anthropic schema template, you can upload a spend report CSV directly from the Anthropic console without converting it to the Default CSV format. DataHub validates the Anthropic-specific columns and normalizes them into standard DataHub events.

Export the spend report from Anthropic

To export spend data from the Anthropic console:

  1. Navigate to Settings > Analytics.

  2. Scroll down to the How much is Claude costing? section.

  3. Select Export spend report.

  4. Select a time period: MTD, Last Month, Last 90 Days, or Custom.

    If you select Custom, choose your start and end dates. You can go back up to 90 days, and the most recent data available is from yesterday.

  5. Select Download.

Warning

Do not open, edit, rename, re-save, or otherwise alter the downloaded CSV before uploading it to DataHub. Keep the original filename so the report period can be preserved.

The file must use the Anthropic filename format: spend-report-<report-id>-YYYY-MM-DD-to-YYYY-MM-DD.csv. The file size must not exceed 100 MB.

For more information, see Anthropic's usage analytics documentation.

Anthropic CSV columns

The following table lists the columns expected in an Anthropic spend report CSV.

ColumnRequired
user_emailYes
account_uuidYes
productYes
modelNo
total_requestsYes
total_prompt_tokensYes
total_completion_tokensYes
total_net_spend_usdYes
total_gross_spend_usdYes
total_uncached_input_tokensYes
total_cache_read_tokensYes
total_cache_write_5m_tokensYes
total_cache_write_1h_tokensYes
total_web_search_countYes
user_idNo
slack_channel_idNo

These columns are present in the standard Anthropic spend report export. DataHub rejects files with missing required columns, duplicate columns, or unrecognized columns.

Overlap restrictions

DataHub does not allow overlapping report periods within the same dataset. If you upload a report whose date range overlaps with a previous upload, the upload is rejected. To replace or correct data for an overlapping period, delete the existing batch first and then upload the new report.

Upload CSV

Required permission
  • DataHub Admin

The description below explains how to upload a CSV file using the console. For uploading CSV using the DataHub API, see DataHub API.

Once you formatted the CSV file correctly, you can upload it when creating a new dataset or updating a dataset.

  1. In the Import data dialog, select Upload CSV file, and then select Continue.

    Import data options

  2. Prepare file: Review the instructions for your dataset's schema template. For the Default template, make sure your CSV file complies with the Syntax and conventions. For the Anthropic template, follow the steps in Export the spend report from Anthropic. Select Next to continue.

  3. Upload CSV: Select the CSV file to upload. This step also validates the CSV.

    Upload CSV step 2

  4. Preview: In this step, you verify that the data will be ingested with the desired dimensions and metrics.

    Upload CSV step 2

After you select Confirm upload, we start processing the data. When the data has been uploaded successfully, it can take up to 15 minutes for the data to become available in the console.