Building an automated reporting solution with Datylon Report Server
Closing the gap between engaging report designs and automated delivery of personalized information is not trivial. Given the right tools and a structured approach, things do become manageable. The benefits of such efforts are substantial. Getting the right information delivered at the right time packaged as a captivating data story, makes all the difference between actionable knowledge and data lost in the information overload we all deal with on a daily basis.
In what follows Datylon Report Studio and Datylon Report Server are used to set up a simple yet ‘realistic’ and fully functional report automation scenario. The report was designed using Datylon for Illustrator and uploaded as templates to Datylon Report Studio. The look & feel of the templates can be changed at any time, without needing to edit anything in the scripts. The creative process, while crucial for an impactful end-to-end report delivery flow, is not further discussed here.
The complete script is available in a public bitbucket repo.
The README information stored in the repository should give you enough information to run the report renderings and play around with it.
Report data
The (fictive) example data from which the report will be created summarizes survey responses covering certain traits and skills of employees. It is stored in an Excel workbook with four sheets:
- Personality: per employee survey results on the personality traits
- Communication: per employee survey results with respect to an employee’s communication style
- Skill: per employee communication skills
- Benchmarks: benchmark metrics to compare the employee’s score with
The report data is available here.
The report
The three-page report was created using Datylon for Illustrator and exported to Datylon Report Studio after which each of the pages was downloaded as SVG. These are available at the following URLs:
- Page 1 summarizes responses to ‘personality’ questions
- Page 2 summarizes responses to ‘communication style’ questions
- Page 3 summarizes responses to ‘interpersonal skill’ questions
You can also download the Adobe Illustrator file containing Datylon charts. If you choose to do so, make sure you also register, download, and install the Datylon for Illustrator plugin (a 14-day free trial is available here).
Automating report rendering
The demo database contains information about 20 different survey respondents. To automate the creation of a three-page report summarizing each of the respondent's data, a Python script was created. The following steps were implemented
- The Excel workbook is read using the Python Pandas library.
- The data is converted into the JSON structures expected by the different Datylon designs. To find out the structure to use, open the design in Datylon Report Studio and download the ‘attached data’ as JSON.
- For each of the three pages, and for each of the respondents, the Datylon render server is invoked using Python’s request package in order to render the Datylon design as a PDF file with the respondent’s specific data.
- For each of the respondents, the three PDF files are merged into one document using the pypdf2 library.
The final reports (PDF files) are stored on the local disc but can easily be transferred or distributed using any delivery channel that supports PDF documents.
Automating report rendering - code snippets
The complete Python script is available from the Datylon public bitbucket repository. A few representative snippets are provided below.
Configure the script
(src/config.py)
datylon_url = "https://insights.datylon.com/datyrender/api/render" |
Note that the Datylon Report Studio user and password are taken from environment variables and should be set before attempting to run the script.
Reading the data
(src/gen_reports.py)
def read_data(file_path): |
Filtering the data
Each of the reports should only contain the data for one survey respondent. As such the data has to be filtered using the respondent’s name for which the report is being created.
(src/data_binding.py)
... |
Converting the data to JSON
The biggest part of the code deals with transforming the data from its input structure (the workbook sheets) to the data the designs expect when rendering with the Datylon Render Server.
For each Datylon workbook sheet, a JSON object is created. The code creates these objects ‘sheet’ per ‘sheet’ and then concatenates the results.
Below is a code snippet to illustrate the process.
(src/data_binding.py)
def p1(personality, benchmarks, respondent,json): |
After all JSON objects are created, they are merged into one JSON object.
def build_json(data, respondent): |
Invoking the render server
Once the JSON has been constructed using data extracted from the excel workbook, the Datylon Render server can be invoked, one invocation for each of the three pages of the design and for each of the respondents’ survey data.
A single invocation looks like this:
auth_string = f"{username}:{password}" |
The constructed JSON is used as the POST request payload (a complete example of such JSON can be found here. The UUID of the Datylon design is passed in as the x-graph-template-id header.
Concatenating the pages
Finally, once the three pages of the design for a given survey respondent have been rendered, they can easily be concatenated to create one final PDF report. The file is named using the respondent name (selected_person_name.pdf).
pdfs = PyPDF2.PdfMerger() |
The complete script is available in a public bitbucket repo. The README information stored in the repository should give you enough information to run the report renderings and play around with it.
Conclusion
This paper illustrates a simple approach to setting up a report automation system based on the Datylon platform. The code fragments are designed to be easily adaptable and can serve as inspiration for the reader to create context-specific workflows.
By synergizing the creative capabilities of Adobe Illustrator with the power of the Datylon Illustrator Plugin and the developer-friendly Datylon Render Server API, a versatile Report Automation workflow emerges, requiring minimal development efforts.
Interested in experiencing the Datylon Report Server firsthand? Book a demo and let one of our experts guide you through its capabilities.
Further reading
What is automated data reporting? A complete guide
Climbing the Ladder of Automated Reporting Solutions with Datylon
The Great Report Debate: Manual, Automated, or Interactive?
Automated reports: Defining Data Resources, Data Extraction and Transformation Options
Mastering Versioned Stand-Alone Reports
Building an automated reporting solution with Datylon Report Server
Automated Data Visualization Trends: What to Look for in Report Server Tools
Automated reporting for various industries:
Revolutionizing Marketing and Media: The Power of Automated Reporting
Automated Reporting in Asset and Wealth Management: Trends and Best Practices
Boosting Efficiency: How Automated Reporting Transforms Associations
The Power of Automated Reporting in the Pharmaceutical Industry
Peter Coppens - Founder & CTO
Peter has a strong passion to create software technology to solve customer problems in a pragmatic way. Being an experienced software engineer, he’s generous with his knowledge while constantly being eager to learn new approaches himself.