-Hey gues, knocking my head over this one.
I have a datatable with 600+ rows in one column. Like this:
456874-645510008091Kontrollerahögnettolön.
698548-659810008091Kontrollerahögnettolön.
558744-887410008091Kontrollerahögnettolön.
Now, i’d like to insert spaces after the 11th character and after the 19th character so the it ends up like:
456874-6455 10008091 Kontrollerahögnettolön.
698548-6598 10008091Kontrollerahögnettolön.
558744-8874 10008091 Kontrollerahögnettolön.
Fine
welcome to UiPath community
hope these steps would help you resolve this
–use excel application scope and pass the file path as input
–inside the scope use a read range activity and get theoutput with a variable of type datatable named dt
–now use a for each row loop and pass the datatable variable dt as input
–inside the loop use a assign activity like this row(0).ToString = row(0).ToString.SubString(0,11)+" " +row(0).ToString.SubString(11,8)+" "+row(0).ToString.SubString(19,row(0).ToString.Length-19).ToString
do i assign it to a new variable right? tried to change variable type to string but that produces an error saying it cnat convert from boolean to string.
This is the exception error:
RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at UiPath.Core.Activities.ForEach`1.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance,
ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)
and activitiinfo:
“Name”: “For Each Row”,
“Id”: “1.12”,
“InstanceId”: “9”,
“TypeName”: “UiPath.Core.Activities.ForEachRow”
Fine
Kindly check once whether the DTRow2 has any value in it
for that use WRITELINE activity and mention like this DTRow2.Rows.Count.ToString
if this gives us more than 0 in the output panel then fine
else we need to check the excel file
and
try in sequence rather to flowchart (unless we dont have multiple decision making)
Hey, yeah the writeline gives 10344 so that seems ok.
Created a new variable to hold the datatable: DTRaw. when i try to assign your suggestion to the DTRaw variable i get this error:
i got the issue
in assign activity this must be in left side row(0)
while this must be in right side of equal to in assign activity row(0).ToString.SubString(0,11)+" " +row(0).ToString.SubString(11,8)+" "+row(0).ToString.SubString(19,row(0).ToString.Length-19).ToString
yah it was a typo mistake
it should be only row(0) in the left side
fine row(0).ToString.SubString(0,11)+" " +row(0).ToString.SubString(11,8)+" "+row(0).ToString.SubString(19,row(0).ToString.Length-19).ToString
this expression should work
is ADD HEADERS is enabled in the READ RANGE activity
Cheers @thomasb82
hey, yeah tried both with add headers and without,theres no headers in the datafile though, still same error. and no, not all lines are the same length,98% are though, one or two rows are longer…
that is they are all the same up until the 11th character, then there seems to be one or two that are different.but ive tried with just 5 rows that are the same and still seem to get the paramter length error…