Commit bb22c05d authored by Bruno Duyé's avatar Bruno Duyé
Browse files

Fix: make periods compatible with DBnomics format

parent 2c97a7d4
......@@ -38,6 +38,7 @@ Options:
import logging
import os
import re
import shutil
import sys
......@@ -215,6 +216,12 @@ def write_series(indicator_code, observations_source_json_path, dataset_target_p
log_or_raise("{!r}/{!r} series: two values for period {!r} ! Values: {!r}".format(
dataset_code, series_code, period, (last_observation_tuple[1], observation_tuple[1])
# Transform period to match DBnomics format (ex: "1990Q1" => "1990-Q1")
quarter_period_re = r'^(\d{4})Q(\d)$'
match = re.match(quarter_period_re, period)
if match:
period = "{}-Q{}".format(,
# Write observation to file
observations_file.write("\t".join((period, observation)) + "\n")
last_observation_tuple = observation_tuple
return {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment