Read CSV file in Power Automate and bulk generate documents

This article demonstrates how to read CSV files in Power Automate (Microsoft Flow) using Parse CSV action from Plumsail Documents connector. We will use results from this action to bulk generate documents.

Additionally, you can watch the video guide here:

For example, a company might have a CSV file containing customer information and want to bulk generate conference invitations for all customers, then print and send them using the postal service.

We will read a CSV file and use the available headers to populate the invitation template and generate PDF file. The invitation in PDF format will be a result file of Create DOCX document from template action. To populate the DOCX template we are going to use Parse CSV output items.

Our source CSV file, as well as DOCX template need to be stored somewhere. Power Automate (Microsoft Flow) has a lot of connectors for different systems.

Here are just a few of them:

  • SharePoint

  • Salesforce

  • Box

  • OneDrive

  • Google Drive

  • Dropbox

  • SFTP

  • File System

In this example, we will store our source CSV file and DOCX template in a OneDrive folder, although you can retrieve data from any other sources. These are links to download the demo files:

This is how our flow looks:

Parse CSV flow

Below is a step-by-step breakdown of the flow.

Parsing a CSV file

Flow trigger

First, you need to open Power Automate and create an Instant cloud flow. You can pick any trigger, for example, you can start a flow on file creation in a SharePoint document library. We will use Instant cloud flow and Manually trigger a flow to simplify the flow. Give it a name and click Create.

Flow trigger

Get file content - CSV

This action retrieves the specified file from a OneDrive folder. In this case, we need to select our CSV file. First, click on New Step and find OneDrive.

Connect OneDrive

Next, we need to find Get file content action.

Get file content

Finally, specify the path to your file. You can also rename this step to Get CSV file so it is easier to find it in the next steps of the flow.

Get CSV file

You can use any other connector to get files from your system.

Get file content - DOCX template

We need to click New step and follow the same steps as above, but this time, choose our DOCX file. As you can see, we renamed this step to Get DOCX template content as well.

Get DOCX template file

Parsing CSV

This is an action from Plumsail Documents connector.

Click New step, and find Plumsail Documents.

Connect Plumsail Documents

If this is your first time connecting to Plumsail Documents in Power Automate you will need to establish a connection by creating an API Key in your Plumsail account.

API Key

It is an easy process. Log in to your Plumsail Account, click on Document, then API Keys and Add key.

Add API Key

Give your Key a name and click Create.

Create API Key

Copy the Secret Key number.

Copy API Key

Go back to Power Automate and paste both the API Key number and Connection Name. Click Create. You are all set!

Enter API Key in PowerAutomate

Next, find and select Parse CSV action.

Parse CSV action

Next, place CSV file content from the output of the previous action by selecting Get CSV content.

Place CSV file content

In the Headers field, specify the headers from your CSV file. This will allow you to select them in the Dynamic content window in the next step. In our example, we are going to use the customer’s first name, last name and the company name. Find more detailed information about Parse CSV action.

Parse CSV action - headers

Generating PDF files from DOCX document

Click Next step, connect Plumsail Documents and look up Create DOCX document from template.

Create DOCX Document From Template

In the Template file field, we need to select Get DOCX template content to pull our DOCX file.

Get DOCX template content

The next field, Template Data, is an object, that will be applied to our DOCX template. In our case, we are applying just two columns from our CSV to the template: FirstName and LastName. You can find more information about creating documents from templates here. In the Document output type, you can choose to convert the file to PDF or keep it in DOCX format. We are selecting PDF.

Template Data and convert to PDF

Saving bulk generated PDF files to OneDrive

To wrap up this flow, we will save our bulk-generated PDF invitations in a OneDrive folder.

First, we need to add an action inside the Create DOCX document from template. Click Add an action.

Add an action

Next, you need to connect to OneDrive.

Connect to OneDrive

Find and select Create file action.

Create file action

In the Folder Path field, select a OneDrive folder, where the bulk-generated PDF invitations will be saved after we run the flow.

For the File Name field, we apply Company column from our CSV file, and we add .PDF file extension. You can choose another column, such as Email or ID, if needed.

In the File Content field, insert Result file from the Create DOCX document from template action above.

Click Save. Now, you can run the flow and find the PDF invitations in the OneDrive folder.

Create File Action, Save

In just a few steps the flow is configured. This simple automation can help you ease the work with documents.

You can find more detailed information about Parse CSV action here.