Hi Im trying to remove the 1st 2 numbers in my list but i cant seem to make it work i always get a null value whenever i use a substring(0, str-2) function i even tried remove but what it removes is the last 2 digits of my numbers my sample number is 0420 and i want to remove the 04 and get the 20.
Help is greatly appreciated I have been stuck in this problem since 2days ago.
Hello, I have a similar requirement. I am reading (1,00) such value into a variable and i want to use only 1 out of the string and ignore the zeroes. how can i use Sub-string in this case?
Hi Mahesh,
your solution is more flexible,as it is working with all values. thanks !!
I need to do a summation of this column, containing comma values like… 1,00 2,00 10,00 etc. Comma represents decimal notation so i need to ignore the zeroes and consider only preceeding value. I tried using “Compute(SUM(columnname)” but it won’t work… how can i alter the values in datatable itself and do the summation?
I scraped a structured data from the web. The problem is that some string in the data contains comma, and when I put the structured data in a csv that’s a problem because I can’t divide it properly with the unwanted comma.
How can I scan over the entire structured data to remove the comma and afterwards write the csv?
the problem is my data type is a data table, not a single variable type string. I think I should iterate over it with a for cycle for example. is that correct?
Indeed, that would be the approach. I am pretty sure someone knows a 1-liner for that in an Assign activity, but they would have to speak up (maybe @ClaytonM, if he feels like it; I don’t like using direct tags like that )
From my understanding, you can’t change row items in a datatable without using a For Each to loop through each row.
Also, you don’t necessarily need to remove the comma because if you surround that item with quotes, then the CSV will delimit the value correctly.
So basically if would look like this:
For each activity: For each row in dt1
If row.Item("columnname").ToString.Contains(",")
Assign: row.Item("columnname") = """"+ row.Item("columnname").ToString+""""
// or row.Item("columnname") = row.Item("columnname").ToString.Replace(",","")
So that would loop through each row and change the value using an Assign activity.
If the data has thousands of rows, this may not be an efficient solution. The other method would be to manipulate the entire structured data as a string (ie using Output Data Table). However, if you look at the entire row as one string, I don’t know how you would identify which commas are delimiters and which commas need to be removed.
EDIT: added if condition in pseudocode to check if value contains comma
Oh, you can also filter your table prior to replacing the commas, rather than looping through each row.
That would be like this:
For Each (Framework) activity: For each row in dt1.AsEnumerable.Where(Function(r) r("columnname").ToString.Contains(",") ).ToArray
Assign: row("columnname") = """"+ row.Item("columnname").ToString+""""
// or row.Item("columnname") = row.Item("columnname").ToString.Replace(",","")
I am used to programming in python where I can put I piece of code essentially where I want to, but in this platform where should I copy paste your piece of code to be executed??