In this Power Automate tutorial, I will show you how to import data from a csv file to a SharePoint list using Power Automate. The same steps you can follow to import data from Excel to a sharepoint list using power automate.
I have a CSV file i.e. ‘Username’, which is stored in the SharePoint document library. So, we will create an instant cloud flow that will get and parse the CSV data and then we will store it in a SharePoint list called Username using Power Automate.
The CSV file ‘Username’ contains the below columns:
- Username
- Identifier
- First name
- Last name
The SharePoint list ‘Username’ contains the below column:
- Username (Title)- Single line of text
- Identifier – Number
- First name- Single line of text
- Last name- Single line of text
Now, we will create a flow that will save data from CSV to SharePoint list using Power Automate.
Save CSV or Excel Data to a SharePoint List in Power Automate
Here we will see how to save CSV or Excel data to the SharePoint list using Power Automate.
Before we start creating flow in Power Automate, make sure you have the CSV file uploaded in the SharePoint document library. And you have created the above SharePoint list with the columns as it is.
Step 1: Log in to Power Automate, and click on +Create, select Instant Cloud flow.
Then provide the flow name, and select the Manually trigger a flow action. Then click on Create.
Now, you can see Manually triggered flow is added to the flow page.
Step 2: Next, we will get the the content of csv file, so, click on the +New step -> select Get file content using the path action. Then provide the below information:
- Site address: Select or provide the SharePoint site address.
- File path: Provide the file path.
Step 3: Now we will convert the above content into a string, so, click on the +New step -> select Compose action. Then provide the below information.
- Inputs: Provide the below expression:
string(outputs('Get_file_content_using_path')?['body'])
Step 4: Next click on the +New step -> select Compose action. Then provide the below information.
Inputs: Here click on Enter to create a new line.
Similarly, create 3 compose actions, and provide the below information in the Inputs field
- Compose -split rows
split(outputs('Compose-csv_content'),outputs('Compose-new_line'))
- Compose-split by new line
split(outputs('Compose-csv_content'),outputs('Compose-new_line'))
- Compose -get fields name
split(first(outputs('Compose-split_by_new_line')),',')
Step 5: Next we will skip the first row of data, that can field heading, and we will use the heading in mapping. So, click on the +New step -> select ‘Select‘ action. Then provide the below information:
- From: In this Provide the below expression:
skip(outputs('Compose-split_by_new_line'),1)
- Map: To map the field column with value, after that, it will return an array.
Key | Value |
---|---|
outputs(‘Compose_-get_fields_name’)[0] | split(item(),’,’)?[0] |
outputs(‘Compose_-get_fields_name’)[1] | split(item(),’,’)?[1] |
outputs(‘Compose_-get_fields_name’)[2] | split(item(),’,’)?[2] |
outputs(‘Compose_-get_fields_name’)[3] | split(item(),’,’)?[3] |
Step 6: Next, click on the +New step -> select Initialize variable action. Then provide the below information:
- Name: Provide the name as Items.
- Type: Select the type as Array.
Step 7: Now I will remove the last item from an array, it contains array value. So, click on the +New step -> click on the Apply to each action. Then provide the below information:
- Select an output from previous steps: Provide the below expression:
take(body('Select'), sub(length(body('Select')),1))
Next, click on Add an action -> select ‘Append to array variable‘ action. Then provide the below information:
- Name: Select items from the drop-down.
- Value: Select the Current item from dynamic content.
Step 8: So, click on the +New step -> select Parse json action. Then provide the below information:
- Content: Select the var from the dynamic content.
- Schema: To get the schema, click on ‘Generate from sample‘ and then provide the output. Click on Done.
Step 9: At last, click on the +New step -> select Create item action. Then provide the below information:
- Site address: Select the SharePoint site address.
- List name: Select the List from the dynamic content
- Title: Select the Username from dynamic content
- Identifier: Provide the below expression from dynamic content.
items('Apply_to_each_2')['Identifier']
- First name: Provide the first name from the dynamic content
- Last name: provide the last name from dynamic content
Step 10: To run the flow, click on Save -> then click on the Test icon -> then select Manually -> click on the Test button. Next, configure the flow -> click on Run flow -> Click on Done.
Now you can see, the flow runs successfully and all the CSV data are saved into the SharePoint list automatically using Power Automate.
Conclusion
In this Power Automate tutorial, we saw how to import csv data to a SharePoint list using Power Automate. So, I hope you got an idea on how to import data from Excel to a sharepoint list using power automate.
You may also like:
- Add Attachments to SharePoint List Items using Power Automate
- How to Merge Word Documents in Power Automate
- How to remove an item from an array in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.