110 likes | 125 Views
Machina Automation. Fast-Track UiPath Developer Module 4: Retrieving and Working With Data. 4 – Retrieving and Working with Data. Overview : This module covers ways that you can get data and work with it in UiPath. Organization : This module is organized into the following sections:
E N D
Machina Automation Fast-Track UiPath Developer Module 4: Retrieving and Working With Data
4 – Retrieving and Working with Data • Overview: This module covers ways that you can get data and work with it in UiPath. • Organization: This module is organized into the following sections: • 4.1: Get Data From Excel • 4.2: Get Data From SQL • 4.3: Data Tables • 4.4: List vs Array • 4.5: Dictionary(TKey, TValue)
4.1 – Get Data From Excel • App Integration > Excel vs System > File > Workbook • There are two sets of activities that can be used to interact with Excel: • App Integration > Excel • Can interact directly with .xlsx files to read and write data • Must use an Excel Application Scope to attach to an Excel file • Can work with Excel files (.xlsx) even if Excel is not installed, with Visible parameter turned off • System > File > Workbook • Can interact directly with .xlsx files to read and write data • Does not require an Excel Application Scope • Can work with Excel files without Excel being installed • Work completely in the background
4.1 – Get Data From Excel • Read Range: Reads the specified Range from the specified Sheet into a Data Table • Write Range: Writes a Data Table to the specified Range in the specified Sheet
4.2 – Get Data From SQL • Make sure that you have the UiPath.Database.Activities package installed • This provides you with these activities: • Example 4.1
4.3 – Data Tables • DataTable variables represent a type of variable that can store big pieces of information, and act as a database or a simple spreadsheet with rows and columns. They can be found in the Browse and Select a .Net Type window, under the System.Data namespace (System.Data.DataTable). • These variables can be useful to migrate specific data from a database to another, extract information from a website and store it locally in a spreadsheet and many others. • UiPath supports VB.Net style lambda expressions, such as: longWords = words.Where(Function(w) w.length > 10) • Linq expressions are also supported, such as: (((From dr As Datarow In dtWhere Convert.ToString(dr(“ColumnA”))=“2”Select Convert.ToString(dr(“ColumnB”))).ToList()).Distinct()).ToList
4.3 – Data Tables • There are several activities that can be used to create and interact with Data Tables: • You will get practice using Data Tables in later exercises
4.4 – Array vs List • Array: • The array variable is a type of variable which enables you to store multiple values of the same type. • UiPath Studio supports as many types of arrays as it does types of variables. This means that you can create an array of numbers, one of strings, one of boolean values and so on. • List: • A List is a type of variable that stores a collection of values that can have any number of elements (dynamic) • Use the Add to Collection activity to add items to a List
4.4 – Array vs List Complete Exercise 4.1
4.5 – Dictionary(TKey, TValue) • Dictionaries are types of variables that store key – value pairs • To create a new dictionary, it must be initialized with “new Dictionary(Of String, String)” (assuming that both the TKey and TValue are strings). • Make sure that you have the Microsoft.Activities.Extensions package installed. This package provides the following activities for interacting with dictionaries:
4.5 – Dictionary(TKey, TValue) • Values stored in Dictionary variables can be accessed in this way... name = dictionaryVar(“Name”).ToString • ‘name’ is the variable being assigned the value • ‘dictionaryVar’ is the name of the Dictionary variable • “Name” is the TKey