PPA Tools: CSV
Summary
This module contains actions used to create CSV spreadsheets.
Actions
ppa_tools.csv.
create_from_dictionaries
Generate CSV data from a list of dictionaries & keys.
Minimum Plugin Version: 5.0.0
Input
-
header: a list of table column headers
-
keys: a list of corresponding dictionary keys, one for each
header
-
dictionaries: a list of dictionaries to get the values of each
key
from
Output
The generated CSV as a string.
Example
-
Creating a CSV spreadsheet of Active Directory users in the Domain Admins group
-
Writing the CSV spreadsheet to a file
-
Sending the file as an email attachment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Headers & Keys
The header
& keys
lists must be the same length, & the attributes must be in the same order.
If a supplied key is missing from a dictionary, its value will be blank.
ppa_tools.csv.
create_from_table
Generate CSV data from a table header & rows.
Minimum Plugin Version: 5.0.0
Input
-
header: a list of table column headers
-
rows: a list of lists where each inner list contains each cell value
Output
The generated CSV as a string.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Header & Row Length
Each list inside the rows
input must be the same length as the supplied header
.
ppa_tools.csv.
read_file
Read a CSV file into a list of dictionaries.
Minimum Plugin Version: 10.2.0
Input
- name: the name of the CSV file to read
Columns & Row Lengths
The columns will be extracted from the first line of the CSV file.
Please ensure every row has one cell per column.
Output
A list of dictionaries where each dictionary is a row, & each key is a column name.
The columns are taken from the first line of the CSV file.
See the example below for more information.
Example
Example users.csv file:
1 2 3 |
|
Playbook snippet:
1 2 3 |
|
The value of the users
variable will be:
- sAMAccountName: first.user
givenName: first
sn: user
mail: first.user@domain.net
- sAMAccountName: second.user
givenName: second
sn: user
mail: second.user@domain.net