For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/en/guides/public-cloud/data-platform/tutorials-eco2mix-forecast.md.
Skip to content

Collect the daily electricity consumption of French regions

View as Markdown

Find out how to load 13 years of regional electricity consumption, add real-time data every morning and model both in an hourly SQL view for a forecast

Objective

This guide walks you through building the data a regional electricity forecast needs: 13 years of consumption history for the 12 regions of mainland France, completed every morning with the latest data published by the French transmission system operator, RTE. You load the history from a file with a File Upload source, connect the real-time data with an HTTP REST source, date and deduplicate each collection with Data Processing Engine, then merge both into an hourly view. Everything in this part happens in the Data Platform interface and in SQL.

By the end you will have two tables, eco2mix_regional_history and eco2mix_regional_realtime (the second one updated every morning by a scheduled workflow), and the view regional_consumption_hourly: one row per region and per hour, from January 2013 to today. The second part of the guide, Forecast the electricity consumption of each region every day with PySpark, trains a forecast model on this view in a notebook, then runs it every morning as a scheduled job.

Requirements

To follow this guide you need:

  • a Data Platform project.
  • the history file below, exported from the public ODRÉ API. The real-time API is public too: neither needs an account or a key.
FileDownload
Regional consumption from January 2013, five columns, times in UTC (about 13 MB)Parquet export on ODRÉ

Save the file as eco2mix_regional_history.parquet: this guide uses that name.

Info

About the data: éCO2mix regional consumption by RTE, published by Open Data Réseaux Énergies (ODRÉ) under the Licence Ouverte 2.0: the consolidated and definitive data for the history and the real time data for the daily collection.

When you reuse these data, mention their source and the date of their last update.

We recommend completing the Getting Started guides first. This guide assumes you are comfortable with the main components of Data Platform.

What you will build

StageComponentResult
1. Load the regional historyFile Upload source, Analyzer and Lakehouse Manager tableseco2mix_regional_history, 2.9 million half hours
2. Connect the real-time dataHTTP REST source and Load actioneco2mix_regional_realtime, the recent weeks by quarter hour
3. Keep one row per quarter hourSQL action and Deduplicate actionEvery row dated, no duplicate after a new collection
4. Model the data in hoursLakehouse Manager viewsregional_consumption_hourly, readable by Trino and by Spark
5. Schedule the collectionWorkflow and a triggerOne collection every morning at 06:17 UTC

Instructions

Step 1: Loading the regional history

The history covers the 12 regions of mainland France, half hour by half hour. Corsica is not part of the dataset.

The file listed in the Requirements is the export of the ODRÉ dataset, limited to five columns, with times in UTC:

https://odre.opendatasoft.com/api/explore/v2.1/catalog/datasets/eco2mix-regional-cons-def/exports/parquet?select=code_insee_region,libelle_region,nature,date_heure,consommation&timezone=UTC

The download can take a few minutes. The figures in this guide come from an export dated 20 October 2026, which ends on 31 August 2026: a later export covers more months, and the real-time data takes over after its last row.

Creating the source

  1. Open Connectors > Sources and create a new source of type File Upload.
  2. Name it eco2mix_regional_history.
  3. In the Files section, drop eco2mix_regional_history.parquet or use click here to upload.
  4. Click Create.
The File Upload source eco2mix_regional_history with the file eco2mix_regional_history.parquet in its Files section

Checking the attributes

  1. Open Connectors > Analyzer.
  2. Select the source eco2mix_regional_history, then eco2mix_regional_history.parquet.
  3. Click Extract metadata.

The Analyzer detects the types on a sample of 1,000 rows. Check them now: they become the types of the attributes of the table.

AttributeDetected typeWhat to know
code_insee_regionDoubleText in the file, converted to a number by the Analyzer. The view of Step 4 turns it into an integer.
libelle_regionStringThe name of the region.
natureStringThe status of the data, for example Données consolidées.
date_heureDateTimeThe Analyzer adds a blueprint rule on its own, Datetime remove timezone: it removes the time zone and keeps the UTC time.
consommationDoubleThe consumption, in MW.
The Analyzer showing the five attributes of eco2mix_regional_history.parquet and a blueprint on date_heure

The file is sorted from the most recent row to the oldest: in the export of 20 October 2026, its first row is 2026-08-31 21:30 UTC, and the sample of 1,000 rows covers a little under two days of late August 2026. The Explorer gives the full picture once the table is loaded.

Creating the table

  1. Open Lakehouse Manager > Tables and click New table > Create from a Connectors source.
  2. Select eco2mix_regional_history.parquet from the source eco2mix_regional_history, then click Next.
  3. Name the table eco2mix_regional_history, keep the dataset default_dataset, and keep the 3 options turned on: Automatically build the table, Automatically load the table once and Automatically generate Load action for later.
  4. Click Create, then wait for the first load to finish.
The Create table window with the name eco2mix_regional_history, dataset default_dataset and three options turned on

Checking the history

In Lakehouse Manager > Explorer, run:

SELECT count(*) AS rows,
       count(consommation) AS with_consumption,
       count(DISTINCT code_insee_region) AS regions,
       count(DISTINCT CAST(code_insee_region AS varchar) || CAST(date_heure AS varchar)) AS distinct_region_timestamps,
       min(date_heure) AS first_row,
       max(date_heure) AS last_row
FROM eco2mix_regional_history

With the export of 20 October 2026:

rowswith_consumptionregionsdistinct_region_timestampsfirst_rowlast_row
2,874,8162,874,792122,874,4802012-12-31 23:002026-08-31 21:30
The Explorer with the check query on eco2mix_regional_history and its single row of results

What these figures say:

  • 12 regions, every half hour, from 1 January 2013 to 31 August 2026, Paris time. The first row, 2012-12-31 23:00 UTC, is midnight in Paris.
  • 336 duplicates (rows minus distinct_region_timestamps). The dataset follows Paris time: on the day clocks go forward in spring, the hour that does not exist in Paris time appears twice in UTC, that is, two half hours per region each spring. In autumn, the hour that occurs twice in Paris time is missing in UTC. The hourly view of Step 4 averages all the points of an hour, duplicates included.
  • 24 empty consumptions: for each region, the first half hour of 1 January 2013 and of 1 January 2026, where a new series starts (definitive data, then consolidated data).

Step 2: Connecting the real-time data

The real-time dataset only keeps recent months: older months move to the consolidated dataset. The export of 20 October 2026 stops on 31 August 2026, and the real-time data takes over from 1 September.

Creating the source

  1. Open Connectors > Sources and create a new source of type HTTP REST.

  2. Name it eco2mix_realtime.

  3. In Base URL, enter https://odre.opendatasoft.com/api/explore/v2.1/. The API is public: keep Authentication mode set to None, then click Connect.

  4. In Endpoints to connect, click Add an endpoint and fill in the endpoint:

    SettingValue
    MethodGET
    Endpoint/catalog/datasets/eco2mix-regional-tr/exports/json
    Query tab, parameter selectcode_insee_region,libelle_region,nature,date_heure,consommation
    Query tab, parameter timezoneUTC
    Source object technical name, in the Options tabregional
  5. Click Confirm.

    The Configure an endpoint window with the GET method and query parameters
  6. Click Create.

    The source lists one endpoint, regional.json.

    The source eco2mix_realtime with the ODRÉ base URL and the endpoint regional.json

Two choices matter here:

  • The export endpoint, not records: the records endpoint returns a limited number of rows per call; the export endpoint returns the whole dataset at once.
  • No date filter: the real-time dataset only holds recent data anyway, and each collection overlaps the previous one. Step 3 removes the overlap.

Checking the attributes

In Connectors > Analyzer, select the source eco2mix_realtime, then regional.json, and click Extract metadata. You get the same types as for the history: code_insee_region Double, date_heure DateTime with the same blueprint, consommation Double. Unlike the history file, this JSON is sorted from the oldest row to the most recent.

Creating the table from the history table

The real-time table has the same columns as the history, plus the time of each collection. Start from a copy of the history table:

  1. Open Lakehouse Manager > Tables, hover over the row of eco2mix_regional_history and click its Duplicate icon. The Create new empty table window opens with the name eco2mix_regional_history_copy.
  2. Rename the table eco2mix_regional_realtime, keep the dataset default_dataset and click Create.
  3. Open the table eco2mix_regional_realtime, then its Schema tab.
  4. Click New attribute, name it collected_at, select the data type Datetime and click Save.
  5. Click Build.
The Schema tab of eco2mix_regional_realtime with collected_at added in Datetime
Info

Note: the copy keeps the identifier field of the original table, date_heure. Leave it as it is: in this guide, the Deduplicate action of Step 3 handles the key of a row (the region and the quarter hour).

Creating the Load action

  1. Open Data Processing Engine > Actions, click New action and select the Load action.
  2. In Sources, select regional.json from eco2mix_realtime. In Destination, select eco2mix_regional_realtime from default_dataset.
  3. The five attributes map to the attributes of the same name. Leave collected_at without a source: the SQL action of Step 3 fills it.
  4. Rename the action Load regional realtime.
  5. Click Create, then Run.
The Load action from regional.json to eco2mix_regional_realtime with its attribute mapping

Checking the real-time data

In the Explorer, run:

SELECT count(*) AS rows,
       count(consommation) AS with_consumption,
       count(DISTINCT code_insee_region) AS regions,
       min(date_heure) AS first_row,
       max(date_heure) AS last_row
FROM eco2mix_regional_realtime

On 23 November 2026, the table holds 96,768 rows: 12 regions × 96 quarter hours × 84 days, from 2026-08-31 22:00 UTC, right after the last row of the history, to the end of the current day. The real-time data is published by quarter hour, and lists every quarter hour of the current day in advance: the ones not measured yet have an empty consumption. It has no row for tomorrow.

Step 3: Keeping one row per quarter hour

Each collection loads all the recent weeks again. To keep one row per region and quarter hour, you date each collection, then keep the most recent row of each quarter hour.

Dating each collection

Create an SQL action that dates the rows that have just been loaded.

  1. In Data Processing Engine > Actions, click New action and select the SQL action.

  2. Name it Stamp regional collection.

  3. In the Tables panel, click the copy icon of eco2mix_regional_realtime: an SQL action needs the full name catalog.schema.table, and the catalog name, db_<id>_default_dataset, is specific to your project.

  4. Paste the query below, with that full name in place of <catalog>.default_dataset.eco2mix_regional_realtime:

    UPDATE <catalog>.default_dataset.eco2mix_regional_realtime
    SET collected_at = CAST(current_timestamp AT TIME ZONE 'UTC' AS timestamp(6))
    WHERE collected_at IS NULL
  5. Click Validate. Validation is a dry run: it checks the query without changing the table.

  6. Click Create.

The SQL action Stamp regional collection with its UPDATE query successfully validated

Seeing the Load action append

  1. Run Stamp regional collection.

  2. Run Load regional realtime again.

  3. In the Explorer, run:

    SELECT count(*) AS rows,
           count(collected_at) AS stamped,
           count(*) - count(collected_at) AS not_stamped,
           count(DISTINCT collected_at) AS collections
    FROM eco2mix_regional_realtime

The table now holds twice as many rows: 193,536, of which 96,768 stamped by the first collection and 96,768 not stamped yet. The Load action appends every row it reads: each collection is kept, and the next step keeps the most recent row of each quarter hour.

The Explorer showing 193,536 rows in eco2mix_regional_realtime, 96,768 stamped, 96,768 not stamped and one collection

Keeping the most recent row

  1. Run Stamp regional collection again: the new rows get a more recent collection time.

  2. In Data Processing Engine > Actions, click New action and select the Deduplicate action.

  3. Fill in the action:

    SettingValue
    Tableeco2mix_regional_realtime from default_dataset
    Key column(s)code_insee_region, date_heure
    Row to keepMost recent / oldest entry, then Most recent, ordered by the column collected_at
    Keep a backup of this tableOff: Time Travel already keeps the previous state

    The action notes that this key differs from the identifier fields of the table: this is expected, since the key here is the region and the quarter hour.

  4. Click Scan: it estimates, without changing anything, how many rows the key would remove. It finds 96,768 rows to remove, one per region and quarter hour.

  5. Click Create. The action is named Deduplicate - eco2mix_regional_realtime. Run it.

    The Deduplicate action on eco2mix_regional_realtime with the key date_heure and code_insee_region, the most recent row kept by collected_at, and a Scan that finds 96,768 rows to remove

Run the count query again: the table is back to 96,768 rows, all stamped.

Why append then deduplicate, rather than empty the table and reload it? RTE removes older months from the real-time dataset, and the history file stops at the end of the last consolidated month. Emptying the table before each load would lose the months that are no longer in the real-time data and not yet in the history.

Step 4: Modelling the data in hours

The view regional_consumption_hourly merges the history and the real-time data into one row per region and per hour.

  1. Open Lakehouse Manager > Views and click New View.

  2. Name the view regional_consumption_hourly and select the dataset default_dataset.

  3. Enter the definition below. Write table names only: the platform resolves their catalog and schema.

    WITH all_rows AS (
        SELECT code_insee_region, libelle_region, nature, date_heure, consommation
        FROM eco2mix_regional_history
        UNION ALL
        SELECT code_insee_region, libelle_region, nature, date_heure, consommation
        FROM eco2mix_regional_realtime
        WHERE date_heure > (SELECT max(date_heure) FROM eco2mix_regional_history)
    )
    SELECT
        CAST(code_insee_region AS BIGINT) AS region_code,
        max(libelle_region) AS region_name,
        date_trunc('hour', date_heure) AS hour_utc,
        avg(consommation) AS consumption_mw,
        count(consommation) AS consumption_points,
        max(nature) AS nature
    FROM all_rows
    GROUP BY CAST(code_insee_region AS BIGINT), date_trunc('hour', date_heure)
  4. Click Create.

The Create a new view window with regional_consumption_hourly, default_dataset and its SQL definition

The rules behind this view:

  • The history comes first: the real-time data is only read after the last row of the history.
  • One hour is the average of its points, in UTC: two half hours in the history, four quarter hours in the real-time data. Staying in UTC avoids the autumn trap, when two UTC hours fall on the same Paris hour.
  • Portable SQL: Trino reads this view in the Explorer, and Spark reads it in the notebook and in the job of the second part. The view only uses SQL both engines know: the functions, operators and types specific to Trino, such as with_timezone, AT TIME ZONE, timestamp(6) or day_of_week, stay out of it, and Paris time is computed where the view is read.
  • The region code is a BIGINT, a type both engines share.
  • Table names only: the platform resolves the catalog and the schema of the tables, for Trino and for Spark alike.

Checking the view

In the Explorer, a view is prefixed with its dataset:

SELECT region_code, region_name,
       count(*) AS hours,
       count(consumption_mw) AS measured_hours,
       min(hour_utc) AS first_hour,
       max(hour_utc) AS last_hour
FROM default_dataset.regional_consumption_hourly
GROUP BY region_code, region_name
ORDER BY region_code

On 23 November 2026, each region has 121,786 hours, from 2012-12-31 23:00 to 2026-11-23 22:00 UTC. 121,776 of them are measured, 121,777 in Bourgogne-Franche-Comté: the remaining 10, or 9, are the hours of the current day not measured yet.

Explorer: regional_consumption_hourly, 121,786 hours per region from 2012-12-31 23:00 to 2026-11-23 22:00

Step 5: Scheduling the collection

Stopping the workflow on failure

If one action of the collection fails, the next ones must not run on incomplete data. For each of the three actions, Load regional realtime, Stamp regional collection and Deduplicate - eco2mix_regional_realtime:

  1. Open the action, then its Preferences tab.
  2. In the Timeout options section, turn on Stop workflow on failure.
The Preferences tab of Load regional realtime with Stop workflow on failure turned on

Creating the workflow

  1. Open Data Processing Engine > Workflows and click New workflow.

  2. Name it Daily realtime collection.

  3. In the workflow builder, click Add your first action, then select Load regional realtime in the Action list of the side panel.

  4. Click the + of Load regional realtime, then Add action after, and select Stamp regional collection.

  5. Click the + of Stamp regional collection, then Add action after, and select Deduplicate - eco2mix_regional_realtime.

  6. Click Create.

    The workflow builder of Daily realtime collection, with Load regional realtime, Stamp regional collection and Deduplicate - eco2mix_regional_realtime linked one after the other

Each action waits for the one before it: in its side panel, the Dependencies tab shows Runs after and the previous action. Actions that do not wait for each other can run at the same time, which is why each one is added with Add action after rather than Add parallel action.

Scheduling it

In the Preferences tab of the workflow, in the Triggers section, click Add and fill in the time-based trigger:

SettingValue
NameEvery morning
TypeCron
ModeAdvanced
Expression17 6 * * *

Click Confirm.

The New trigger window with the daily cron expression at 06:17 UTC in Advanced mode

The workflow runs every day at 06:17 UTC: schedules are in UTC, while the interface shows times in the time zone of your browser, 07:17 in winter and 08:17 in summer for a browser set to French time.

Checking a run

Click Run to start a first collection now. It takes a little over a minute. The logs show a warning on collected_at, which has no mapping attribute in the Load action: this is expected, since the SQL action fills it.

Preferences tab of the Daily realtime collection workflow after a 66-second run, with its logs

What you have built

You have 13 years of regional consumption, completed every morning by a three-step workflow that loads, dates and deduplicates the real-time data of RTE. You also have a view that merges both into one row per region and per hour, readable by Trino and by Spark.

The next part, Forecast the electricity consumption of each region every day with PySpark, explores this view in a notebook, trains one forecast model per region with PySpark, then turns the notebook into a scheduled Custom PySpark job, with its logs, its Spark History, its lineage and a daily check of its accuracy.

Go further

For training or technical assistance implementing our solutions, contact your sales representative or visit our Professional Services page to request a quote and have your project analysed by our experts.

Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated Discord channel.

If you need support with your OVHcloud services, create a request in our Help Centre.

Join our community of users.

Was this page helpful?