Skip to main content

Notifications

Power Automate - Building Flows
Answered

Read CSV file and create/update list items with logic

Posted on by 1,594

Hi all,

 

I have a CSV file in a SharePoint Online library.

I'd like to create a FLOW that goes through each line of the CSV file and, using a bit of logic, create or update items in a list.

 

By example, if my CSV file is the following:

Last name;First name;Email

SMITH;Allan;a.smith@outlook.com

DOE;John;jdoe@outlook.com

 

If a have a list with the following:

Last name | First name | Email

DOE | John | john.doe@hotmail.com

 

When I run the workflow, I'd like to do the following:

  • when processing first line of CSV file (SMITH), since it does not exist in the list -> creates a new item in the list for SMITH
  • when processing second line of CSV file (DOE), since it already exist but email is different -> update list item to set new email for John DOE

The resulting list would then look like this:

Last name | First name | Email

DOE | John | jdoe@outlook.com

SMITH | Allan | a.smith@outlook.com

 

Is this possible ? Anyone already done something similar ?

 

Thanks for the help,

 

Emmanuel

  • fritz77 Profile Picture
    fritz77 6 on at
    Re: Read CSV file and create/update list items with logic

    Hi, I'm trying to use your solution but I get a strange behavior: the first 5 rows in Sharepoint list have one field empty while all the others show correctly the field value. I tried to re-run the flow starting from the same excel to update the values and I get the same result.

     

    I checked the input and output of every step of the flow and I can find the correct value in the correct field but not in the Sharepoint list. The excel file is correct, the value in this rows are formatted correctly and are all plain text.

     

    Any idea?

  • fritz77 Profile Picture
    fritz77 6 on at
    Re: Read CSV file and create/update list items with logic

    Hi, I'm trying to use your solution but I get a strange behavior: the first 5 rows in Sharepoint list have one field empty while all the others show correctly the field value. I tried to re-run the flow starting from the same excel to update the values and I get the same result.

     

    I checked the input and output of every step of the flow and I can find the correct value in the correct field but not in the Sharepoint list. The excel file is correct, the value in this rows are formatted correctly and are all plain text.

     

    Any idea?

  • takolota1 Profile Picture
    takolota1 4,754 on at
    Re: Read CSV file and create/update list items with logic

    Hello,

     

    Please see this template if you want to parse a CSV without 3rd party connectors. It works even if there are commas in the data.

     

    https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-to-Dataset/td-p/1508191

     

    For this use-case, you can insert a Filter array action after the last Select action to filter the Select output before parsing the JSON to dynamic content.

  • SergiPino Profile Picture
    SergiPino 6 on at
    Re: Read CSV file and create/update list items with logic

    for problem #2 you can use a flow trigger "when file is created"

    SergiPino_0-1602764100279.png

    then check if this file is the csv converted into .xlsx and if it's the case fire the rest of the flow.

     

    I did this on other flows and works like a charm.

  • Re: Read CSV file and create/update list items with logic

    Using Shell Scripts you can. Unfortunately there is no such feature in Flow yet. I use VBA macros but that involves manual intervention.

     

    Cheers,

    Aamir

  • Re: Read CSV file and create/update list items with logic

    can i set the power query to run twice a day?

  • Re: Read CSV file and create/update list items with logic

    The feature is not available right now. I had a similar issue where I paste my csv in a SharePoint folder and I managed to build a workaround.

    1. Create an Excel file.

    2. Use PowerQuery to read the csv from the Sharepoint.

    3. Use flow to to read the queried table in Excel.

    4. Update/Replace the Csv as required.

     

    Cheers,

    Aamir

     

  • anton-khrit Profile Picture
    anton-khrit 219 on at
    Re: Read CSV file and create/update list items with logic

    You can use Parse CSV action from Plumsail Documents connector. It allows you to convert CSV into an array and variables for each column. Please read this article demonstrating how it works.

     

    Then you can iterate through result array and create items in a SharePoint list according to your logic.

  • R3dKap Profile Picture
    R3dKap 1,594 on at
    Re: Read CSV file and create/update list items with logic

    Well, on my side I'll never get to the million records...

     

    On the other hand, I totally agree wih you @asdfaf4 about the fact that Excel file paths cannot be dynamic and that's really a pain... Hope this feature will come true one day...

  • asdfaf4 Profile Picture
    asdfaf4 169 on at
    Re: Read CSV file and create/update list items with logic

    2 potential problems by converting to Excel...

     

    1. Limit of 1 million rows

    2. Using Excel in flow doesn't support dynamics path and filename, you have to select the file within flow.  This defeats the purpose of having a library where a flow fires when a new file being added.  Highly frustrating...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard