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 / PAD CSV bracket issue ...
Power Automate
Unanswered

PAD CSV bracket issue with PowerShell

(1) ShareShare
ReportReport
Posted on by 8

I am working on making a Flow to create new AD users.  In trying to create the list of variables from a .CSV file, PAD seems to be adding brackets to the variables when reading from a CSV.  This is causing the brackets to be included in the PAD variable when passing, causing issue with my PowerShell script.   All functions perfectly when reading from an Excel file.   Is there a way to filter/remove out the highlighted brackets when PAD is reading the CSV? 

I have attached screenshots to show the differences in variables between .csv & .xls.
I am trying to manage the resources needed and cutting out Excel from my flow would be helpful.

csv_issue.png
excel_noi.png
I have the same question (0)
  • Kannan_n Profile Picture
    511 Super User 2024 Season 1 on at

    @LostSquirrel 

     

    I have 1 suggestion for this.

    Before start flow go to your CSV File

    >> Open You  CSV

    >>CTRL+F(You will get find pop up)

    >>Switch to find and replace 

    >> there in Find First put [ After replace put blank ""

    >>Click replace all 

    >> do again for ]

    >>After save and run your flow 

    Kannan_n_0-1678229807924.png

     

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    As @Kannan_n sugested - you need to clean your csv file before reading it.

    However the quicker method will be:

     

    1. Read content of the file to variable - do not use read csv though, use read text file

    2. Replace text using replace text (you can use regex: [|] to reaplce both brackets using one action

    3. Save clean text back to the csv file (overwirte existing content)

    4. Only then read from csv

  • Pavel_NaNoi Profile Picture
    1,074 on at

    Its a list, those brackets therefore mean nothing as they just signify it is one, they don't get passed anywhere, something else must be the issue, I could be wrong for this particular case though so, if you want to remove those brackets just use a "Set Variable" onto the items you've extracted for each one, see if the issue persists after that.

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    Indeed! I just took a look at the screen and they do get this as a list

    so if this code is executed in a loop, I would skip all of the "set variables" or  "retrieve column" and I would do "for each" on the data table, and then reference %currentitem% in the PS command.

  • LostSquirrel Profile Picture
    8 on at

    Out of curiosity I passed the Retrieve Data Table in list variables in a Create new data table.  It seems as though PAD has now added an extra set of brackets.  But when passed to a message box for testing those brackets do not appear.  Seems odd to me that doing the same flow but using an .XLS Sheet into same Column into List does not retrieve or show these brackets, and works flawless with the same PS Script. 
      These [ ] exist nowhere but inside PAD somewhere it seems when reading a .CSV, but somehow translates to an error in PS Script, always showing a   "   before each variable output. 

    Example:  Display message displays Zero as first name.  Flow variable shows [Zero].  PS Script Error outputs "Zero

    I have even converted this to a cloud flow triggering a PAD Flow passing a SharePoint list column output  into variables over the last week, and I am still getting the same issue from the variables when it comes to passing them.
      Time to rethink my approach I guess.  As of right now my script is pulling in a RemAD Import Module.  My hope is re-scripting to work on the local server it will be on, will help narrow it down if it is PS related.

    Still baffled by the way variables are handled in PAD when it comes to Execl Read Column to List vs CSV Read Column to List.

    Feel free to shell out any other suggestions as I've tried countless ways to find or filter out any [ ] or " . 

    Screenshot 2023-03-09 173650.png
    Screenshot 2023-03-09 173323.png
  • Pavel_NaNoi Profile Picture
    1,074 on at

    I'm going to need to see the rest of your code to see if I could even replicate this, I'm 75% sure this isn't a brackets issue. Once again I'm stating that they mean nothing and are just there for visibility reasons so you know you're dealing with a list, meanwhile try the following to find out 100% that its not any of that:

     

    -  Use "Replace Text" action with the following regular expression [\[\]"] and replace it with %""% (how PAD reads nulls)

     

    If that works then you were correct, otherwise try the this next regular expression:

     

    -  \n+ and replace once again with %""%, also use a "Trim Text" action on the same list.

    Also note that these actions will turn your values into variables rather than lists.

     

    Finally if that doesn't work try using excel actions to write into a blank excel sheet and see what is written, if its as you expect then just read from this excel sheet the values you've written, otherwise if they're completely different and have weird symbols in them then its most likely that the text from the .csv file has some special characters that need to be filtered out via the replace action I mentioned earlier.

  • LostSquirrel Profile Picture
    8 on at

    Ran a small Flow just to grab the first name from the column & ran a few options.  Set variable seems to still show the brackets.  But running the Replace Text on the List Item, First Name variable seems to remove it. 
    Don't know if we are onto something here.
    When I have more time, I will re-write my flow to use the Replace Text output variables and see if PowerShell still has issues.

    csv_function.png

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 284 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 188 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 144 Super User 2026 Season 2

Last 30 days Overall leaderboard