﻿# Generate Content Constraint from file

This functionality allows the user to create a content constraint just by uploading a CSV file. The "Generate CC from file" option is selectable from the utility menu

![CC from file utilities](_static/img/Utilities-GenerateCCFromFile.PNG "CC from file utilities")

Once the user clicks on the menu, this window appears:

![CC from file](_static/img/cc_from_file.PNG "CC from file")

While the first two tabs are the same as the ones seen in the [**Content Constraint **](content_constraints.md) paragraph, in the **Load File** tab the system displays the mask for acquiring data from CSV files.
The required fields for loading from CSV file are:
- *File* (mandatory)
- *Separator* (mandatory, it is pre-set with ";")
- *Delimiter* (optional)

The user can load the file by clicking on the "Upload file" button and after loading the CSV it is possible to view the data (“Preview” button).
Only after completion of the minimum and mandatory information, the System activates the save function using the **Save** button. The new content constraint will then be accessible in the "Content Constraint" section
in the Meta Manager menu.

![CC from file upload](_static/img/GenerateCCfromF_3.PNG "CC from file upload")

Hereby is a possible example of a CSV file used for CC creation. Considering that neither time_period or non-coded dimensions/attributes are considered while reading a file for CC creation, the user can create
a simple csv file containing these columns:

![File example](_static/img/fileEx.PNG "CC from file upload")

the header must have the same names used as ids in the DSD declaration. Each column indicates the dimension/attribute with the items the user wants to allow in his content constraint. The example
specifies that possible items for:
- FREQ are "A" and "M";
- MARKET are "T","D" and "E";
- REF_AREA is just "IT";
- ADJUSTMENT is "N";
- INDICATOR is "TURN";
- ACTIVITY are "0040", "0050" and "0080";
- BASE_PER is "2015";
- UNIT_MEASURE is "IX";
- SOURCE is "ISTAT".

If this content constraint will then be used to validate the upload data operation (during the Loader step), an error will be shown if the uploaded file contains items that differ from the once allowed. \
For example, given the rules described earlier, a row containing an item different from T,D or E for the MARKET dimension, will cause an error message like this:

![File error](_static/img/fileEx_err.PNG "Upload with error")

It is also possible to download data from a dataflow and use it as input to generate the content constraint keeping only the information the user wants to use in order to create a CC.

![File from dataflow](_static/img/file_from_dataflow.PNG "File from dataflow")