|
2 | 2 | import os |
3 | 3 | import uuid |
4 | 4 | import pandas as pd |
| 5 | +import urllib3 |
5 | 6 |
|
6 | 7 | from fds.analyticsapi.engines import ApiException |
7 | 8 | from fds.analyticsapi.engines.api.pa_calculations_api import PACalculationsApi |
|
32 | 33 | from fds.analyticsapi.engines.model.column_statistic import ColumnStatistic |
33 | 34 | from fds.analyticsapi.engines.api.groups_api import GroupsApi |
34 | 35 | from fds.analyticsapi.engines.model.group import Group |
| 36 | +from fds.protobuf.stach.extensions.v2.StachUtilities import StachUtilities |
35 | 37 |
|
36 | 38 | from urllib3 import Retry |
| 39 | +urllib3.disable_warnings() |
37 | 40 |
|
38 | 41 | host = os.environ['FACTSET_HOST'] |
39 | 42 | fds_username = os.environ['FACTSET_USERNAME'] |
@@ -229,11 +232,26 @@ def main(): |
229 | 232 |
|
230 | 233 | def output_calculation_result(result): |
231 | 234 | print("Calculation Result") |
232 | | - stachBuilder = StachExtensionFactory.get_row_organized_builder( |
233 | | - StachVersion.V2) |
234 | | - stachExtension = stachBuilder.set_package(pkg=result).build() |
| 235 | + metadata_list = [] |
| 236 | + stachBuilder = StachExtensionFactory.get_row_organized_builder(StachVersion.V2) |
| 237 | + stachExtension = stachBuilder.set_package(result).build() |
235 | 238 | dataFramesList = stachExtension.convert_to_dataframe() |
| 239 | + MetaData = stachExtension.get_metadata() |
236 | 240 | print(dataFramesList) |
| 241 | + print('\n MetaData:') |
| 242 | + for metadataItem in MetaData: |
| 243 | + metadata_dict = {} |
| 244 | + for keyName in metadataItem: |
| 245 | + appendedMetadata = ','.join(str(StachUtilities.get_value(x)) for x in metadataItem[keyName]) |
| 246 | + metadata_dict[keyName] = appendedMetadata |
| 247 | + metadata_list.append(metadata_dict) |
| 248 | + |
| 249 | + metadata_df = pd.DataFrame(metadata_list) |
| 250 | + # Set display options for better readability |
| 251 | + pd.set_option('display.max_rows', None) |
| 252 | + pd.set_option('display.max_columns', None) |
| 253 | + pd.set_option('display.width', None) |
| 254 | + print(metadata_df.to_string(index=False, header=True, justify='left', col_space=20)) |
237 | 255 | # generate_excel(dataFramesList) # Uncomment this line to get the result in table format exported to excel file. |
238 | 256 |
|
239 | 257 |
|
|
0 commit comments