To construct the tabular single column (TSC) format output, you need the metadata and grid data for the view.
To retrieve the view metadata and grid data:
- Use the Retrieve metadata for dimensions on a view call to retrieve the view metadata.
The response contains the names of dimensions as well as the number of dimensions on rows and columns. This procedure assumes output headers follow the order in the metadata response.
- Use the Retrieve cell data for a view call to retrieve your grid view data.
- Parse the first line of the grid view output and store it as a list.
If the view has no dimensions on pages, the list is empty and you will not need it for the transformation.
In the following module view, we will transform the Grid CSV output to TSC format.
To construct the first line of the TSC format, we retrieve the metadata for the view as it contains the names of the dimensions, as well as information that will be useful later, such as the number of dimensions on rows and columns.
In this example, we assume that the output headers follow the order within the metadata response, with
pages dimensions being first, followed by dimensions on
columns , dimensions on
Value at the end.
We retrieve the cell data for the view using the API.
Jan 14 ,Apples
,UK ,France,Germany,Total Company
Units Sold,10 ,20 ,30 ,60
Produced ,100 ,200 ,300 ,600
Whitespace is added to this example response for readability.
To extract the page items, we parse the first line of the Grid output and store it as a list called PageItems:
PageItems = [Jan14; Apples]