Scripts package

Scripts.charts module

Provides a series of functions which will run against Chart shapes within PowerPoint, after the Chart Shape has been filled.

Scripts.charts.add_axis_labels_to_bar_chart(Chart=None)

On a Bar chart, generate text shapes within the Chart shape, to the left of the plot area, and place the labels of the axis within these shapes. This enables more formatting within the labels, for example, left/right/center justification.

Parameters:Chart – Chart shape, default = None
Scripts.charts.convert_glyphs_to_color_wingdings(Chart, Matrix=None, rgb=[])

Convert your significant results into up and down arrows within the chart.

Parameters:
  • Chart – Chart shape
  • Matrix – Matrix associated with the selection, default = None
  • rgb – list containing RGB values. Default is [255,255,255], which will display as white.

Used in conjunction with a transformation script, convert_significance_results_to_arrows, which sets the significant results to display the character values, chr(0xE9), chr(0xEA) which will then be converted into arrows when this function is run.

Example, in the transformations script:

tr = transformations.MatrixManipulator(Matrix)
tr.convert_significance_results_to_arrows()

And in the afterfill action:

import charts
charts.convert_glyphs_to_color_wingdings(Chart, Matrix, rgb=[0,0,0])
Scripts.charts.make_topN_shapes_on_chart(Chart, Matrix, list_of_topN_scores)

Make and align TopN text shapes within the chart to the top or side of each category column or bar, within a clustered or stacked chart.

The topN text shape will be placed outside the top or side of the plot area, within the chart shape.

Parameters:
  • Chart – Chart shape
  • Matrix – Matrix associated with the Chart
  • list_of_topN_scores – the Top N scores from either within the Matrix, or calculated from existing rows of the Matrix.

For example:

list_of_topN_scores = [‘10.3%’, ‘12.5%’, ‘8.7%’, ‘29.6%’, ‘22.2%’, ‘30.0%’]
charts.make_topN_shapes_on_chart(Chart, Matrix, list_of_topN_scores)
Scripts.charts.set_colors_on_chart(Chart, Matrix, fileName=None)

Assign a specific color to each brand within a column, bar, pie, line chart, based upon values in an input text file.

This function is often used when a chart has been sorted as the display order will be updated between refreshes of data.

Parameters:
  • Chart – Chart shape
  • Matrix – Matrix associated with the Chart
  • fileName – path and file containing the brands and colours to be used for the chart series.

The script expects an input file to be passed as a parameter, or else will use “colors.txt” in the same folder as the pptx file, and contains the following format:

“Brand Name”,Red,Green,Blue.

Example:

colors.txt contains:

“Brand name 1”,0,154,130
“Brand name 2”,0,131,190
“Brand name 3”,154,158,31
“Brand name 4”,170,22,62

set_colors_on_chart(Chart, Matrix, colors.txt)

Scripts.shapes module

Provides a series of functions which will run against any PowerPoint shape, after the Shape has been filled.

Scripts.shapes.RGB(r, g, b)

Convert RGB values to ColorTranslator value for PowerPoint.

Scripts.shapes.find_shape(Shapes, shape_name)

Find a shape with a specific name within your PowerPoint slide.

It can be used to delete existing shapes, so that they can be re-generated, or to select a specific shape to apply a function to.

Example:

labelShape =find_shape(slide.Shapes,”mySlideName”)
if(labelShape != None):
labelShape.Delete()
else:
break
Parameters:
  • Shapes – PowerPoint Shapes.
  • shape_name – Text name of the shape.
Scripts.shapes.set_background_color(Shape, red, green, blue)

Set the background colour for the shape to an RGB value.

Example:

shapes.set_background_color(Shape, 255, 255, 255)
or
shapes.set_background_color(cell.Shape, 255, 255, 255)

Scripts.tables module

Provides a series of functions which will run against Tables shapes within PowerPoint, after the Tables Shape has been filled.

Scripts.tables.add_group_names_to_table_column_header(Table, Matrix=None)

Add group names to first row table, and merge the heading cells within this row, where the headings match.

NOTE: This function MUST be run with delete_table_row_before_fill() which will delete any previous cell merging from the table. Otherwise the cell merges will be applied to the rows of the filled table.

Parameters:
  • Table – Table shape
  • Matrix – Matrix associated with the Table. Default is None
Scripts.tables.delete_table_row_before_fill()

Manipulate the table before it is filled. Delete first row so that any merged cells are removed before the fill.

NOTE: This needs to be run from the transformations script (not after fill), and is run before any script that will merge cells in the first row.

Note, the Table object is not available from the Transformation script, and therefore the active object is used to find the Table.

Scripts.tables.indent_net_items(Table, Matrix=None)

Indent Net items within a table. Supported up to 1 level of net in the axis.

Parameters:
  • Table – Table shape
  • Matrix – Matrix associated with the Table. Default is None
Scripts.tables.insert_rows_for_group_labels(Table, Matrix=None)

Add in a new row for group headings (including nested group headings) for rows of the table.

The new row will be inserted at the top of each new group or nested group.

Parameters:
  • Table – Table shape
  • Matrix – Matrix associated with the Table. Default is None
Scripts.tables.replace_row_labels_with_group_names(Table, Matrix=None)

Prepend every row in the table with the Group Name.

This function is typically used when making a summary table, for example, displaying Top 2 scores from a selection of scores or tables. Rather than displaying Top 2 for each row, display the group label.

Parameters:
  • Table – Table shape
  • Matrix – Matrix associated with the Table. Default is None

Scripts.texts module

Provides a series of functions which will run against Text shapes within PowerPoint, after the Text Shape has been filled.

Scripts.texts.set_bg_image(_image_file_path, Shape=None)

Sets the Background image of this shape to the _image_file_path.

Used by set_bg_image_and_size.

Example:

_image_file_path = “transformations\utils\images\greenarrow.png”
set_bg_image(_image_file_path)
Scripts.texts.set_bg_image_and_size(_image_file_path, Shape=None)

Set the background of the shape to the image passed in, and resize the shape to the size of the image.

Example:

_image_file_path = “transformations\utils\images\greenarrow.png”
set_bg_image_and_size(_image_file_path)
Scripts.texts.set_bg_picture_center_tile(_image_file_path, Shape)

Centre the Background image within the shape, and tile.

Rescale the image to the current shape.

Example:

_image_file_path = “transformations\utils\images\greenarrow.png”
set_bg_picture_center(Shape,_image_file_path)
Scripts.texts.set_image_based_on_limit(green_limit, yellow_limit, file_name_list, Matrix=None)

Select which image to display based upon limits, for example a traffic light system or up and down arrows.

This should be run per text shape to set the background image and size based on the image selected.

Example:

file_name_list = list()
file_name_list.append(“traffic-light-green.jpg”)
file_name_list.append(“traffic-light-yellow.jpg”)
file_name_list.append(“traffic-light-red.jpg”)

texts.set_image_based_on_limit(0.3, 0.2, file_name_list, Matrix)
Scripts.texts.set_image_in_table_column_based_on_limit(Table, Matrix, image_list, green_limit, yellow_limit)

Within a Table, select which image to display in the last column, based upon limits, for example a traffic light system or up and down arrows.

This should be run per Table, and the background of each cell in the last column will be updated to set the background image and size based on the image selected.

Example:

image_list= [“greenarrow.jpg”,”greyarrow.jpg”,”redarrow.jpg”]
texts.set_image_in_table_column_based_on_limit(Table, Matrix, image_list, 0.2, 0.1)

Scripts.transformations class

Provides a class which merges the series/categories/data and pptx_data modules into one class called MatrixManipulator.

class Scripts.transformations.MatrixManipulator(matrix)

Bases: Scripts.transformations.series.MatrixSeriesManipulator, Scripts.transformations.categories.MatrixCategoryManipulator, Scripts.transformations.data.MatrixDataManipulator, Scripts.transformations.pptx_data.PowerPointDataManipulator

Class for manipulating labels or values from the series, categories, or data values of a matrix, or PowerPoint Chart or Table.

This class will import all of the functions from the classes in the parameters list. It is called with a matrix parameter.

Example:

_my_class = MatrixManipulator(Matrix)

Examples:

>>> import utils.matrixfuncs as matrixfuncs
>>> m = matrixfuncs.create_test_matrix()
>>> _my_class = MatrixManipulator(m)
>>> print _my_class.get_series_labels()  #taken from series module
[u'myRow 0', u'myRow 1', u'myRow 2', u'myRow 3', u'myRow 4']
>>> print _my_class.get_category_labels() #taken from categories module
[u'myColumn 0', u'myColumn 1', u'myColumn 2', u'myColumn 3', u'myColumn 4']
>>> print _my_class.get_series_base_summary() 
myRow 0: 101, myRow 1: 6, myRow 2: 1, myRow 3: 100, myRow 4: 5
>>> print _my_class.get_category_base_summary()
myColumn 0: 101, myColumn 1: 20, myColumn 2: 330, myColumn 3: 102, myColumn 4: 51
>>> _my_class.get_data_values() #taken from data module
[u'101', u'20', u'330', u'102', u'51', u'6', u'7', u'108', u'9', u'10', u'1', u'102', u'3', u'4', u'5', u'100', u'10', u'12', u'13', u'14', u'5', u'6', u'7', u'8', u'109']
category_difference(*args)

Insert a new column and insert the difference between the 2 selected categories, y-x

Parameters:
  • x – First Column in the difference calculation
  • y – Second Column in the difference calculation

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.category_difference(0,1)
clone_matrix(*args)

Clone a matrix into another object for use when manipulating data.

Example:

tr = transformations.MatrixManipulator(Matrix)
clone_matrix = tr.clone_matrix()
convert_significance_results_to_arrows(*args)

Convert your significant results into up and down arrows within your chart.

This script is used in conjunction with charts.convert_glyphs_to_color_wingdings(Chart) function as this changes the font to display the arrows in the data label of the chart.

This example script assumes that the number of cell Items in the table is 1, plus the significance test result is present where appropriate.

This was created using a table which showed significant difference between one column (wave) and the next column (wave) only, so maximum result per cell is 1. In addition, the significance was displayed in the current column if it was significantly higher or lower (sometimes significance results are displayed in the higher column).

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.convert_significance_results_to_arrows()

In the Afterfill action, you will now need to run:

charts.convert_glyphs_to_color_wingdings(Chart)
create_and_fill_dummy_series(*args)

Used with Horizontal stacked charts. Create a dummy series, between each real series (ie every other row) and fill them with values which will pad out a horizontal chart to appear as multiple horizontal charts which are correctly lined up.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.create_and_fill_dummy_series()
del_base_category(*args)

Delete any column containing the word ‘Base’.

The Texts used as ‘Base’ can be amended as required using a list parameter.

Parameters:_list_of_bases – list of texts to be treated as bases. Default = [“Base”, “Unweighted Base”, “Weighted Base”]

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.del_base_category()
or
_list_of_bases = [‘Total’, ‘Base’, ‘All Respondents’]
tr.del_base_category(_list_of_bases)
del_base_series(*args)

Delete any row containing the word ‘Base’

The Texts used as ‘Base’ can be amended as required using a list parameter.

Param:_list_of_bases: list of texts to be treated as bases. Default = [“Base”, “Unweighted Base”, “Weighted Base”]

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.del_base_series()
or
_list_of_bases = [‘Total’, ‘Base’, ‘All Respondents’]
tr.del_base_series(_list_of_bases)
del_categories(*args)

Remove specific categories (columns) labels or indexes from a selection.

For example, delete Don’t know columns from a selection.

Parameters:_list_to_del – This is an array containing text labels or indexes.

It is assumed that if a label is found then the _list_to_del is a list of labels, else it is a list of Indexes.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.del_categories([“myColumn 1”, “myColumn 2”])
or
tr.del_categories([1,2])
del_series(*args)

Remove specific series (row) labels or indexes from a selection.

For example, delete Top 2 / Bottom 2 rows after they have been used for calculating Diff scores.

Parameters:_list_to_del – array containing an array of text labels or indexes.

It is assumed that if a label is found then the _list_to_del is a list of labels, else it is a list of Indexes.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.del_series([“myRow 1”, “myRow 2”])
or
tr.del_series([1,2])
format_percent_as_whole_number(*args)

Set data values that are stored as percentages to be whole numbers

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.format_percent_as_whole_number()
format_whole_number_as_percent(*args)

Set data values that are stored as whole number to be percentages

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.format_whole_number_as_percent()
get_base_column_values(*args)

Return a list of base values from the base (first) row of the matrix. Bases will be returned from columns with Label, Total or Base.

Example:

tr = transformations.MatrixManipulator(Matrix)
base_column_values = tr.get_base_column_values()
get_base_row_values(*args)

Return a list of base values from the base (first) column of the matrix. Bases will be returned from rows with Label, Total or Base.

Example:

tr = transformations.MatrixManipulator(Matrix)
base_row_values = tr.get_base_row_values()
get_category_base_summary(*args)

Return the Base summary of the Row, using the format:

Column Label: Base Value, Column Label: Base Value

Example:

myclass = transformations.MatrixManipulator(Matrix)
base_summary = myclass.get_category_base_summary()
get_category_group_labels(*args)

Return a list containing the category (column) group labels

Example:

myclass = transformations.MatrixManipulator(Matrix)
group_labels = myclass.get_category_group_labels()
get_category_labels(*args)

Return a list containing the category (column) labels

Example:

myclass = transformations.MatrixManipulator(Matrix)
labels = myclass.get_category_labels()
get_data_values(*args)

Return a list of lists containing the data values for each row of the matrix. Only the first cell item will be returned.

Example:

tr = transformations.MatrixManipulator(Matrix)
data_values = tr.get_data_values()
get_dict_cell_values(*args)

Return a dictionary containing the row/column and data values for each cell within the matrix. All cell items will be returned.

Dictionary format:

{
‘row1’:
{
‘col1’: [cell Value1, cell Value2],
‘col2’: [cell Value1, cell Value2]
},
‘row2’:
{
‘col1’: [cell Value1, cell Value2],
‘col2’: [cell Value1, cell Value2]
}
}

Example:

tr = transformations.MatrixManipulator(Matrix)
cell_value_dict = tr.get_dict_cell_values()
get_series_base_summary(*args)

Return the Base summary of the Row with base taken from the first column, using the format:

Row Label: Base Value, Row Label: Base Value

Example:

tr = transformations.MatrixManipulator(Matrix)
series_base_labels = tr.get_series_base_summary()
get_series_group_labels(*args)

Return a list containing the series (row) group labels.

Example:

tr = transformations.MatrixManipulator(Matrix)
group_labels = tr.get_series_group_labels()
get_series_labels(*args)

Return a list containing the series (row) labels.

Example:

tr = transformations.MatrixManipulator(Matrix)
labels = tr.get_series_labels()
insert_category(row_number=0, column_number=0, label='', *args)

Insert a column into the Matrix.

Parameters:
  • column_number – position to insert the column. Default = 0
  • label – label for the inserted column. Default = “”

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.insert_category(column_number=3, label = “Inserted Column”)
insert_gap_between_category_groups(*args)

Insert a blank column between category groups within the Matrix, for charts or tables

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.insert_gap_between_category_groups()
insert_gap_between_series_groups(*args)

Insert a blank row between series groups within the Matrix, for charts or tables

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.insert_gap_between_series_groups()
insert_series(row_number=0, col_number=0, label='', *args)

Insert a row into the Matrix.

Parameters:
  • row_number – position to insert the row. Default = 0
  • label – label for the inserted row. Default = “”

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.insert_series(row_number=2, label = “Inserted Row”)
insert_topN_into_series(*args)

Insert a new row at the top of the series containing topN result

Parameters:N – This is the number of rows to include in the summary row.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.insert_topN_into_series(4)
logger(*args, **kwargs)

Logging functions for writing Log.* messages when run from within PowerPoint or warnings.* messages if run from the command line

make_series_from_grid_slices(*args)

Creates a grid format table from a flat table where you have grid slices appended down the side of the table, and wish these selections to appear as one series.

For example (3 series):

Statement 1 - Top2 X
Statement 2 - Top2 X
Statement 3 - Top2 X

This will appear as (1 series):

____|Statement 1|Statement 2|Statement 3|
Top2|

Note, this does not work when there is nesting or concatenation on the top axis.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.make_series_from_grid_slices()
merge_categories_by_label(*args)

Merges the categories (columns) in the active matrix by their labels.

For example:

_________|January|Februar| March|January|Februar| March|
Brand 1|
Brand 2|

will merge to:

_________|January|Februar| March|
Brand 1|
Brand 2|

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.merge_categories_by_label()
merge_series_by_label(*args)

Merges the series (rows) in the active matrix by their labels.

For example:

_________|January|Februar| March| April| May| June|
Brand 1|
Brand 1|

will merge to:

_________|January|Februar| March| April| May| June|
Brand 1|

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.merge_series_by_label()
number_series(*args)

Number the questions in sequential order in the row headings

Parameters:delimiter – Value to be placed after the statement number, eg ”.” Default “”

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.number_series()
renumber_sig_tests(*args)

Renumber stats test results to ABC order for the selected columns.

If the selection made only contains some columns, then the original Sig test result column names will be confusing when displayed on the slide. You can renumber them to the ABC order before presenting the results on the slide.

Parameters:_warn_when_no_stats – If no Statistics results are present in the Matrix, a warning will be issued. Default value is False

Example:

tr = transformations.MatrixManipulator(Matrix)
_warn_when_no_stats = True
tr.renumber_sig_tests(_warn_when_no_stats)
select_categories(*args)

Keep the categories (columns) found in the array [_list_to_keep], and delete all other columns not in this selection.

This is useful for a select all selection, and then you can pass in an array for which columns you wish to keep for each chart.

Parameters:_list_to_keep – Array containing an array of text labels.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.select_categories([[“myColumn 1”, “myColumn 2”]])
select_series(*args)

Keep the rows found in the array [_list_to_keep], and delete all other rows not in this selection.

This is useful for a select all selection, and then you can pass in an array for which rows you wish to keep for each chart.

Parameters:_list_to_keep – Array containing an array of text labels.

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.select_series([[“myRow 1”, “myRow 2”]])
set_category_base_summary(*args)

Set Labels to category (column) labels with Base Value, using format:

Column Label (Base Value)

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.set_category_base_summary()
set_category_formatted_labels(label_format='{0}', cell_format='{0}', *args)

Set Labels to contain formatted labels of the users’ choice.

Parameters:label_format – Text format using FormatSettings class to format the labels.

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.set_categories_formatted_labels(
label_format=”{0.TopMember.Group.Label} :: {0.TopMember.Label}”)
set_category_groups_formatted_labels(label_format='{0}', cell_format='{0}', *args)

Set Group Labels to contain formatted labels of the users’ choice.

Parameters:label_format – Text format using FormatSettings class to format the labels.

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.set_categories_groups_formatted_labels(
label_format=”{0.Label} :: {0.SortIndex})
set_data_formatted_labels(matrix=None, logger=None, label_format='{0}', cell_format='{0}', *args)

Set Labels of the data cells to contain formatted labels of the users’ choice.

Parameters:cell_format – Text format using FormatSettings class to format the cell values.

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.set_data_formatted_labels(cell_format =
“{0[0].Value} - {0.SideMember.Label} : {0.TopMember.Label}”)
set_series_base_summary(*args)

Set Labels to contain the series (row) labels with Base Value, using format:

Row Label (Base Value)

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.set_series_base_summary()
set_series_formatted_labels(label_format='{0}', cell_format='{0}', *args)

Set Labels to contain formatted labels of the users’ choice.

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.set_series_formatted_labels(label_format =
“{0.SideMember.Group.Label} :: {0.SideMember.Label}”)
set_series_groups_formatted_labels(label_format='{0}', cell_format='{0}', *args)

Set Group Labels to contain formatted labels of the users’ choice.

Example:

myclass = transformations.MatrixManipulator(Matrix)
myclass.set_series_groups_formatted_labels(label_format =
“{0.Label} :: {0.SortIndex}”)
sort_columns(matrix=None, logger=None, by_column=0, by_row=0, using_cell_value=0, descending=True, file_name=None, client_name=None, sort_row=None, *args)

Sorts the columns in the active Matrix numerically, sort within nets and sort nets, if present.

Parameters:
  • by_row – Use the values in this row to determine the sort order of the columns. Default = 0
  • using_cell_value – When there are multiple values within a cell use this to control which value within each cell is used for sorting (zero-based). Default = 0
  • descending – Determines the order in which the values should be sorted. Default = True
  • file_name – A text file containing a list of row names to fix at the end of the sort order on the table/chart. The “file_name” file is located in the pptx folder, and contains a comma separated row, e.g.”Other”,”Don’t know”,”None of these” Default = None
  • client_name – “client_name” is a text string which must match the column label exactly. This column will be placed first in the sort order. Default = None

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.sort_columns()
or
tr.sort_columns(by_row = 1, client_name = “Brand A”)
sort_rows(matrix=None, logger=None, by_column=0, by_row=0, using_cell_value=0, descending=True, file_name=None, client_name=None, sort_row=None, *args)

Sorts the rows in the active Matrix numerically, sort within nets and sort nets, if present.

Parameters:
  • by_column – Use the values in this column to determine the sort order of the rows. Default = 0
  • using_cell_value – When there are multiple values within a cell use this to control which value within each cell is used for sorting (zero-based). Default = 0
  • descending – Determines the order in which the values should be sorted. Default = True
  • file_name – A text file containing a list of row names to fix at the end of the sort order on the table/chart. The “file_name” file is located in the pptx folder, and contains a comma separated row, e.g.”Other”,”Don’t know”,”None of these” Default = None
  • client_name – “client_name” is a text string which must match the row label exactly. This row will be placed first in the sort order. Default = None

Example:

tr = transformations.MatrixManipulator(Matrix)
tr.sort_rows()
or
tr.sort_rows(by_column = 1, client_name = “Brand A”)

Scripts.transformations.auto_fill_matrix module

Provides basic matrix manipulation functions for filling the matrix from the existing current selections.

Note this module is not included in the main transformations class as it requires Connections and Query to be passed as parameters to this class. These are used as the lookup for the Table which as used for the selection. Transformations classes only require the Matrix as a parameter.

Updated October 2016 @author: ccurson

class Scripts.transformations.auto_fill_matrix.FillMatrix(matrix, connections, query)

This class is designed to be used when handling very large reports and selecting from large tables. This class will take any existing selections and autofill the matrix with all rows or columns matching the existing selections from the underlying tables.

Parameters:
  • Matrix – Current connected Matrix
  • Connections – Connections to report files found in the current pptx file.
  • Query.Items – Query Items used within the selections in the current Matrix.

Example:

import auto_fill_matrix as fill
myfillclass = fill.FillMatrix(Matrix, Connections, Query)
myfillclass.auto_fill_rows(5, sort=True)
auto_fill_columns(limit_series=None, sort=False)

Automatically fill the columns of the selected Matrix from the underlying connected table.

For example, use Shape settings to select one cell from the required column, and use fillMatrix.auto_fill_columns() to fill up the remaining column from the connected table.

Parameters:
  • limit_series – Only add the first N columns
  • sort – Sort the columns before adding them to the Matrix

Used together, limit_series and sort can enable you to add the top N columns to the selection.

Example:

import transformations.auto_fill_matrix as fill
myfillclass = fill.FillMatrix(Matrix, Connections, Query)
myfillclass.auto_fill_columns(5, sort=True)
auto_fill_rows(limit_series=None, sort=False)

Automatically fill the rows of the selected Matrix from the underlying connected table.

For example, use Shape settings to select one cell from the required row, and use fillMatrix.auto_fill_rows() to fill up the remaining row from the connected table.

Parameters:
  • limit_series – Only add the first N rows
  • sort – Sort the rows before adding them to the Matrix.

Used together, limit_series and sort can enable you to add the top N rows to the selection.

Example:

import transformations.auto_fill_matrix as fill
myfillclass = fill.FillMatrix(Matrix, Connections, Query)
myfillclass.auto_fill_rows(5, sort=True)

Scripts.transformations.labels.format_labels module

class Scripts.transformations.labels.format_labels.FormatSettings(label_format='{0}', cell_format='{0}')

This class is used by a filler whilst outputting text into a chart * the default implementation will a basic str.format approach * more complex implementation should override the formatter function.

For example, the label_format will expect a matrix, member, or group. The cell_format will expect a Cell.

The label_format string can contain whatever the matrix/group/member/cell can format, for example label_format = “{0.Group}: {0}”

The cell_format string can contain whatever the cell can format, eg cell_format = “${0[0].Value} XXX”

Examples:

import transformations.utils.utilities as utils
m = utils.matrixfuncs.create_test_matrix()
from transformations.labels.format_labels import FormatSettings
settings = FormatSettings(label_format=”{0.Member.Label}: ” + “{0[0][0].Value}”)
print ”, ”.join([settings.label_format(r) for r in m])
myRow 0, myRow 1, myRow 2, myRow 3, myRow 4

Scripts.transformations.utils.utilities module

Provides utility functions for use with the Scripts installed with Slides!

Scripts.transformations.utils.utilities.find_table(Connections, query_item)

Using the Queryitems from the selection within the Matrix, look up the Table name and return the connected table.

Scripts.transformations.utils.utilities.print_matrix(matrix, colWidth=11, maxWidth=80)

Print a friendly output representing the current Matrix

Scripts.transformations.utils.utilities.read_comma_separated_file(_file_name, val=None)

Read a named csv file and return the values

This is used within the sort_columns() and sort_rows() functions for reading from a fixed.txt file for fixed position rows/columns within the sorting.

Scripts.transformations.utils.utilities.read_js_file(InputFile)

Provides basic functions for reading and writing to json/java script files.

Use this function to read a js file. The function returns the file.

Parameters:InputFile – the file location of the file you wish to read.

Examples:

input = C:\temp\inputFile.js
json_file=read_js_file(input)
Scripts.transformations.utils.utilities.write_js_file(list, OutputFile)

Provides basic functions for reading and writing to json/java script files.

Use this function to write out a js file.

Parameters:
  • list – the information to be stored in the file.
  • OutputFile – the location you wish to store the file

Examples:

a=list()
a.append(dict(inp=”Some text”, outp=”Some Replacement Text”))
a.append(dict(inp=”Some other text”, outp=”Some Other Replacement Text”))
file = “C:\temp\outputfile.js”
writeJSfile(a,file)

Scripts.transformations.utils.logger module

Scripts.transformations.utils.logger.logger(*args, **kwargs)

Logging functions for writing Log.* messages when run from within PowerPoint or warnings.* messages if run from the command line

Scripts.v4_2_support module

Provides backwards compatibility support for modules that were released with Slides 4.2.

Scripts.v4_2_support.BaseSummaryToCategoryHeadings(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.categories.set_category_base_summary()

Scripts.v4_2_support.BaseSummaryToSeriesHeadings(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.series.set_series_base_summary()

Scripts.v4_2_support.BaseSummaryToTableRows(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.labels.format_labels

Scripts.v4_2_support.ColumnDifference(x, y, Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.data.category_difference()

Scripts.v4_2_support.FindShape(Shapes, shape_name)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.GenerateOverlayAxisLabels(Chart=None)

Adding Backwards compatibility support for v4.2 script.

NOTE: This script will add the shapes within the chart shape, rather than as independent shapes on the slide.

Scripts.v4_2_support.GetCsvVal(file, name)

Adding Backwards compatibility support for v4.2 script

Use transformations.utils.utilities.read_comma_separated_file(_file_name,val)

Scripts.v4_2_support.GetPptImageSize(fileName, Shape=None)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.InsertColumn(colIndex, name='', label='', Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.categories.insert_category()

Scripts.v4_2_support.InsertRow(rowIndex, name='', label='', Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.series.insert_series()

Scripts.v4_2_support.MergeColumnsByLabel(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.data.merge_categories_by_label()

Scripts.v4_2_support.MergeRowsByLabel(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.data.merge_series_by_label()

Scripts.v4_2_support.NumberDownbreaks(delimiter, Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.series.number_series()

Scripts.v4_2_support.NumberStatementsInMatrix(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.series.number_series()

Scripts.v4_2_support.RGB(r, g, b)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.RenumberSigTests(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.data.renumber_sig_tests()

Scripts.v4_2_support.SetBackgroundColor(Shape, red, green, blue)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.SetBgImage(fileName, Shape=None)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.SetBgImageAndSize(fileName, Shape=None)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.SetBgPictureCenter(Shape, fileName)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.SetMatrixLabelToStatement(whichstatement, Matrix=None)

Adding Backwards compatibility support for v4.2 script

Scripts.v4_2_support.SetTrafficLights(greenLimit, yellowLimit, file_name_list=None, Matrix=None)

Adding Backwards compatibility support for v4.2 script.

NOTE: This script will add the shapes within the chart shape, rather than as independent shapes on the slide.

Scripts.v4_2_support.SetTrafficLightsFromMatrix(selectrow, selectcolumn, green_limit, yellow_limit, Table=None, Matrix=None, image_list=None)

Adding Backwards compatibility support for v4.2 script.

This script will update all shapes within the last column of the table, rather than one at a time.

Scripts.v4_2_support.SortColumns(byRow=0, usingCellValue=0, descending=True, Matrix=None)

Adding Backwards compatibility support for v4.2 script

Support for sorting rows using transformations.sorting.sort_columns()

Note: after 4.2 sorting within Nets has been added, and therefore this will give a different result if nets are found.

Scripts.v4_2_support.SortRows(byColumn=0, usingCellValue=0, descending=True, Matrix=None)

Adding Backwards compatibility support for v4.2 script

Support for sorting rows using transformations.sorting.sort_rows()

Note: after 4.2 sorting within Nets has been added, and therefore this will give a different result if nets are found.

Scripts.v4_2_support.TopNStackedBarAlign(shapeToAlign, chartName, categoryNumber, topN)

Adding Backwards compatibility support for v4.2 script.

As an alternative, use the following, which can be called once per chart:

charts.make_topN_shapes_on_chart(Chart, Matrix, list_of_topN_scores)

Scripts.v4_2_support.TopNStackedColumnAlign(shapeToAlign, chartName, categoryNumber, topN)

Adding Backwards compatibility support for v4.2 script.

As an alternative, use the following, which can be called once per chart:

charts.make_topN_shapes_on_chart(Chart, Matrix, list_of_topN_scores)

Scripts.v4_2_support.TopNSummary(N, Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.series.insert_topN_into_series(N)

Scripts.v4_2_support.UngroupRows(Matrix=None)

Adding Backwards compatibility support for v4.2 script

Use transformations.data.make_series_from_grid_slices()

Module contents