How to extract only particular data from Structured data table in UiPath
Introduction:
In UiPath, working with structured data tables is common, especially when automating tasks that involve handling data from spreadsheets, databases, or web scraping. However, extracting only particular data from these tables based on certain criteria can be crucial in many automation processes.
This article will explore different approaches to extracting specific data from a structured DataTable
in UiPath. Here given ex
Extract Table Data
The first step involves extracting data from a source, such as a web page or application, into a DataTable. This is done using the Extract Table Data activity.
- Activity Used: Extract Table Data
- Output Variable: ExtractDataTable
This activity automatically scrapes tabular data from a specified source and stores it in the DataTable variable ExtractDataTable. The extracted data can include any number of rows and columns.Use Case: For example, if you are scraping data from a web page, the Extract Table Data activity can be configured to extract rows of data, such as product listings, search results, or other structured information.
Step 2: Filter Data Table
After extracting the data, you may want to filter it based on certain criteria. This is where the Filter Data Table activity comes in.
- Activity Used: Filter Data Table
- Input DataTable: ExtractDataTable
- Output DataTable: Data
In this activity, you define filter conditions that determine which rows will be kept. For instance, you can filter rows where a specific column meets a condition (e.g., a value in the “Status” column equals “Completed”).
Step 3: Output Data Table
To visualize or log the results of the filtered data, you can use the Output Data Table activity.
- Activity Used: Output Data Table
- Input DataTable: Data
This activity converts the DataTable into a string format, making it easy to log or display the data in a readable format. This is particularly useful for debugging purposes, as you can see the filtered results directly.
Example Output: The filtered data is converted into a string, which can be logged or written to the console for verification.
Step 4: Write Range Workbook
Finally, you can write the filtered data to an Excel file using the Write Range Workbook activity.
- Activity Used: Write Range Workbook
- File Path: “output.xlsx”
- Sheet Name: “sheet1”
- Input DataTable: Data
This activity takes the filtered data from the DataTable and writes it into an Excel file. You can specify the file path, sheet name, and starting cell for the data.
Use Case: The filtered data, such as rows with a specific condition, is written to an Excel file for further analysis or reporting.
Approach 2: Using LINQ Queries
For more complex filtering logic, LINQ queries provide powerful and flexible filtering within UiPath. LINQ allows you to write queries directly in the workflow using Assign activities.
- Write a LINQ Query:
- Use the AsEnumerable() method to work with the rows in the DataTable.
- Apply filtering logic using the Where() method.
- Convert Back to DataTable:
- Use CopyToDataTable() to convert the filtered rows back into a DataTable.
Conclusion:
This workflow demonstrates a powerful automation process in UiPath that combines data extraction, filtering, and writing to an Excel file. By using the Extract Table Data, Filter Data Table, Output Data Table, and Write Range Workbook activities, you can efficiently manage structured data and automate the data handling process.
This type of automation is highly useful in various scenarios, such as scraping data from websites, processing large datasets, or automating reporting tasks.
Also Read – Doc File to PDF Converting Using UiPath