cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lucise
Regular Visitor

How to get last row from csv to the Sharepoint List

Hi,

 

I am learning how to use Power automate and currently struggling with this:

 

I have a csv file with instrument logs - data are generated from several instruments and by python script added to one (always the same) csv file; every run on these instruments generates one row in the csv file (data like ID of the instrument, name of the person, date...). I need to get every instrument log from the csv file into the Sharepoint list, where we collect data from all instruments (some data are added manually).  

 

My idea of perfect flow:

When the csv file is modified (one row is added) power automate flow automatically add the last row from the csv file into the Sharepoint List. 

 

So far I managed to run this flow, where every row from the csv file is added to Sharepoint List: 

Lucise_1-1659530924640.png

The problem is with 2 things:

1. Trigger - recurrence every hour -> it would be better if the flow is triggered when the csv file is modified. 

2. Adding the all rows from csv file to the List -> I need to add only the last (newly added) row - thanks to this I wouldn't need to compare rows in the csv file and the List to find the new ones, the new is always the last one. 

 

I tried to use trigger "When a file is created or modified" but I probably used it wrong way, because there was an error. 

Lucise_2-1659532354515.png

 

Can you help me with how to create this flow?  I managed to add the whole csv file to the Sharepoint List, but that is not enough. I need it automatically updated when a new row in the csv file is added.  

Thanks! 

2 REPLIES 2
eliotcole
Super User
Super User

Hi, @Lucise, it might be better to know why the CSV is the focus here.

 

Where is this CSV coming from?

(which application, service, or connection ... or if it's being dropped in a folder, who/how is that done and where?)

 

Also, please edit into your original question (not a reply) screenshots of your flow as it is right now from the flow edit screen.

 

This will aide anyone wishing to help with context, and help us know that we're not just doing your work for ya 😉. Seriously, though ... *anything* that's an obvious attempt at doing this will help *you* even more, because you'll learn from doing, you can't break it, so don't worry!

 

eliotcole
Super User
Super User

OK, you can have a When a file is created, then ensure that a Trigger condition means that it will only fire for that specific file.

 

I'm assuming that because it's a CSV it isn't updated, rather it is actually replaced when new data is added (otherwise I'd suggest a 'modified' trigger) this will have the new data in it.

 

Anyway, once you have that, then it's easier to simply take the first and last lines from that file.

 

*however*

 

An update may have more than one additional line of added to it. That was was why I was asking questions about where the file is coming from or what is generating it.

 

This presents you with a slightly annoying issue that you need to find out what's already in the list. So identifiers will be needed to be queried, etc.

 

Now, because you have a Python script doing all that work, I would actually advise that you build integration into that to send the data to either a logic app or (premium) HTTP trigger Power Automate flow, to then add the information into a given SharePoint / Microsoft list directly. Who made that Python script? Because they will probably be a good place to start here.

 

Equally, if those instruments have data streams, then there's a chance that those streams can be accessed directly in flow and the data taken more easily.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,910)