Sort CSV

Description

Sort a CSV file by specifying a column for streamlined data organization and customized sorting.

Input Arguments

Input ArgumentTypeDescriptionRequired?Advanced Option?Default
CSVString in CSV formatThe CSV code or a file containing CSV✔️-
Sort columnStringColumn to sort of by. Keep existing sort order by default.-
CSV has Headers?BooleanIndicates if the first row in the CSV contains column headers.✔️Yes
Auto-detect Field Types?BooleanWhether to automatically detect the data types of the CSV fields.✔️No
Number of Rows for Field Type DetectionNumberThe number of rows to analyze for determining field data types (if auto-detection is enabled).✔️20
Remove Empty Rows?BooleanWhether to remove rows that have no data before converting.✔️Yes
Skip a Number of RowsNumberNumber of rows to skip from the start of the CSV before processing.✔️0
Stop at a specific RowNumberRow number at which to stop reading the CSV. If not set, all rows will be processed.✔️convert all rows
SeparatorStringThe character used to separate fields in the CSV. If not set, the separator is auto-detected.✔️Auto-detect separator
Auto-detect Quote Delimiter?BooleanWhether to automatically detect the quote character used to enclose fields in the CSV.✔️Yes
Further sorting columnStringFurther column to sort of by. Blank by default.✔️-
Reverse order?BooleanWhether to sort in descending (true) or ascending (false) order.✔️No

Output

ResponseTypeDescription
CSV ResponseString in CSV formatThe sorted CSV code

Power Automate Examples

Sort CSV

We use a simple CSV with four pets.

Simple CSV with semicolon delimiter
Pet; Identifier;First name;Last name
Dog;1000;Eats;A Lot
Cat;1001;Likes;To Scratch
Cat;1002;Furry;Kitty
Duck;1003;Dagobert;Swimmy

We have not changed the advanced options and indicated the sort column.

Picture

In the advanced options, you can specify the sort column, indicate if the CSV has headers, enable automatic field type detection, set the number of rows for field type detection, remove empty rows, skip or stop at specific rows, define the separator, enable automatic quote delimiter detection, choose a further sorting column, and reverse the sort order.

💡

Looking for the response to this example? Scroll up to see the Output tab.

Known Limitations

⚠️
If you experienced other limitations please get in touch with us!