- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 09:31 AM
I have a Collection with Columns A,B,C as Text Data Type. I want to convert Column B as Number Data Type.
I am using Calc stage within a loop which is taking more time when collection is huge. Do we have any other solution for this ?
Thanks
------------------------------
vinod chinthakindi
------------------------------
Answered! Go to Answer.
Helpful Answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 11:39 AM
Use the following code:
For Each column As System.Data.DataColumn In Input_Collection.Columns
If Field_Name.Equals(column.ColumnName) Then
If CStr(Field_Type).ToUpper.Equals("TEXT") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(String))
ElseIf CStr(Field_Type).ToUpper.Equals("NUMBER") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(Integer))
ElseIf CStr(Field_Type).ToUpper.Equals("FLAG") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(Boolean))
ElseIf CStr(Field_Type).ToUpper.Equals("DATE") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(Date))
Else
Throw New Exception("Invalid File Type Provided")
End If
Else
Output_Collection.Columns.Add(column.ColumnName,column.DataType)
End If
Next
For Each row as System.Data.DataRow In Input_Collection.Rows
Output_Collection.ImportRow(row)
Next
Please find the below screenshots for more reference where we are transforming the 'Age' column from 'Text' to 'Number' :
Code Stage Parameters:
------------------------------
----------------------------------
Hope it helps you and if it resolves you query please mark it as the best answer so that others having the same problem can track the answer easily
Regards,
Devneet Mohanty
Intelligent Automation Consultant
Blueprism 6x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 10:08 AM
Create a collection with the same fields but make the field type of B as number type. Use a calculation stage and assign the original collection to this collection. No loops are required.
For example:
I used a collection called Coll1 with A,B and C field as text and some values as well as shown below.
I used a defined collection call "Coll2" with the fields A,B and C where B is of number type and it has no values.
I just used a calculation stage to store the value of "Coll1" into Coll2" and automatically all the values will get type casted in column B from text to number as shown below:
Values in Coll2:
NOTE : Make sure that all values in field B of Coll1 are proper Numeric values otherwise you will get an exception.
------------------------------
Hope it helps you and if it resolves you query please mark it as the best answer so that others having the same problem can track the answer easily
Regards,
Devneet Mohanty
Intelligent Automation Consultant
Blueprism 6x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 10:15 AM
Let me elaborate my complete query, If I have a collection of 40-50 Columns, I can't go with above solution.
Do you suggest any other solution. Like Coding?
Thanks
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 11:39 AM
Use the following code:
For Each column As System.Data.DataColumn In Input_Collection.Columns
If Field_Name.Equals(column.ColumnName) Then
If CStr(Field_Type).ToUpper.Equals("TEXT") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(String))
ElseIf CStr(Field_Type).ToUpper.Equals("NUMBER") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(Integer))
ElseIf CStr(Field_Type).ToUpper.Equals("FLAG") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(Boolean))
ElseIf CStr(Field_Type).ToUpper.Equals("DATE") Then
Output_Collection.Columns.Add(column.ColumnName,GetType(Date))
Else
Throw New Exception("Invalid File Type Provided")
End If
Else
Output_Collection.Columns.Add(column.ColumnName,column.DataType)
End If
Next
For Each row as System.Data.DataRow In Input_Collection.Rows
Output_Collection.ImportRow(row)
Next
Please find the below screenshots for more reference where we are transforming the 'Age' column from 'Text' to 'Number' :
Code Stage Parameters:
------------------------------
----------------------------------
Hope it helps you and if it resolves you query please mark it as the best answer so that others having the same problem can track the answer easily
Regards,
Devneet Mohanty
Intelligent Automation Consultant
Blueprism 6x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 11:54 AM
I will try your code and will let you know.
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 12:25 PM
Your Code works great. But I have a problem.
In my Case some values will be null then while executing code its throwing an error,
Do we have any solution to handle null Values while converting to Number
Thanks
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 12:36 PM
------------------------------
----------------------------------
Hope it helps you and if it resolves you query please mark it as the best answer so that others having the same problem can track the answer easily
Regards,
Devneet Mohanty
Intelligent Automation Consultant
Blueprism 6x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 12:54 PM
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-11-21 01:45 PM
------------------------------
----------------------------------
Hope it helps you and if it resolves you query please mark it as the best answer so that others having the same problem can track the answer easily
Regards,
Devneet Mohanty
Intelligent Automation Consultant
Blueprism 6x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-12-21 05:12 PM
I have used the above code stage to convert a column from "Text" to "Date". When I open the Output collection, I found that the text column became "Date Time" and also values are not correct.
E.g. one row value was "01/04/2021" as "Text". After the conversion the value became "31/03/2021 23:00:00" (I guess it follows the UTC time)
Please let me know how to resolve this issue. I only need that column in Date format with same data.
Thanks
Ashis
------------------------------
Ashis Kumar Ray
RPA Developer
TCS
Europe/London
------------------------------
