web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to set values for ...
Power Automate
Unanswered

How to set values for each row of a fixed column in a datatable

(0) ShareShare
ReportReport
Posted on by 2

Hi,

I have some CSV files, and I loop through them to read and write them to a large table. However, I need to add a column to each CSV file with the file name written on it. I tried the following method but did not include the file name. Do you have any suggestions? Thanks in advance!

Sophia1111_0-1706770948273.png

 

I have the same question (0)
  • CU31080729-3 Profile Picture
    502 Moderator on at

    Hi,

    As per my understanding you have some csv file and iterate  each of  csv file and read data and you want to add column on each csv file with the name of each csv file respectively. then try this

     

    1) used get files in folder action then you have got each name of file and path of file

    2) then apply loo on it and iterate each file

    3) inside the loop you can

        i) launch excel (from path of each file)

        ii) get last free column

        ii) used add column action (excel) and give the name of this column of file name

        iii) closed excel

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Chetan Ninghot

  • Sophia1111 Profile Picture
    2 on at

    Hi Chetan,

     

    Thank you for your solution! 

    Your understanding is correct. By the way, I would like to explain that the value of each column that needs to be added to a CSV is the file name of that CSV. I followed the steps you mentioned and wrote it down. I am still not quite sure about assigning values to the newly added columns. Could you please help guide me again? Thank you so much!

    Sophia1111_0-1706782394786.png

    Sophia1111_1-1706782420355.png

    Best Regards,

    Sophia

  • CU31080729-3 Profile Picture
    502 Moderator on at

    Hi,

    After inserting the column to excel you can fallow this steps : 

     

    Chetan_Ninghot_0-1706784498403.png

    by using write to excel worksheet you can write column name to your new column , 

     

    Chetan_Ninghot_1-1706784626735.png

    this step work for you.......

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Chetan Ninghot

     

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I would generally suggest avoiding the use of Excel to edit CSV files - it can mess up some of the values there. A CSV file is generally a plain text file, that simply has a bit of syntax for separating elements. You don't need Excel to either read or write to it.

     

    What I would recommend is creating a new data table with as many columns as you have in the CSV file + 1. Then read the CSV file, iterate through its rows, and insert the rows to the new data table one by one. As you do that, add the file name as the last item in the row.

     

    Finally, when the loop ends, write the data table to the CSV file by using Write to CSV file, overwriting previous contents.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 481

#2
11manish Profile Picture

11manish 278

#3
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

Last 30 days Overall leaderboard