Skip to content

Transforming Data

Data conversion — changing one format to another — is supported using the 'read then write' paradigm; this is where a DataReaderEngine reads Series and Observations, and passes the read information directly to the writer.

sdmx-core framework provides the DataTransformationUtil class to perform the copy function

DataReaderEngine dre = ...;
DataWriterEngine dwe = ...;
DataTransformationUtil.copyData(dre, dwe, DataTransformOptions.getInstance());

Or with the ISeriesObsDataWriterEngine interface

DataReaderEngine dre = ...;
ISeriesObsDataWriterEngine dwe = ...;
DataTransformationUtil.copyData(dre, dwe, DataTransformOptions.getInstance());

The default transformation options are to:

  1. Reset the DataReaderEngine before the copy, to ensure it is at the start
  2. NOT to copy the Message Header
  3. Copy all Datasets
  4. Copy all Series
  5. Copy all Observations
  6. Close the writer on completion

These options can be modified by setting the values on the DataTransformOptions.

DataReaderEngine dre = null;
DataWriterEngine dwe = null;
DataTransformOptions options = DataTransformOptions.getInstance()
                                                   .setCloseWriter(false)
                                                   .setDatasetLimit(1)
                                                   .setIncludeAttributes(false)
                                                   .setIncludeObs(false);

//Copy all series keys from source to target
//Ignore observations and all attributes
DataTransformationUtil.copyData(dre, dwe, options);