Convert E- data to specific form

Hello Team,

I need to convert the below data to specific form.

-9.00000068213558E-05 To -9E-05
9.99998155748472E-06 To 9.99998E-06
6.0000027588103E-05 To 6E-05

Can you please give solution to resolve that issue.

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Replace(yourStr,"^[^Ee]+",Function(m) Math.Round(Double.Parse(m.Value),5,MidpointRounding.AwayFromZero).ToString)

Note : It’s assumed input and output are string type.

Regards,

1 Like

Hello Yoichi,

Thank you very much.

1 Like

Hello Yoichi,

Please help me one more time. The issue is while reading the data from excel sheet that time it’s not working. I attached manual output(Actual output) and BOT Output also with input excel file and workflow.
Please seed the issue screenshot .

Please find the attachment and resolve that issue.
BOT_ZHAI.txt (313 Bytes)
Manual_ZHAI.txt (262 Bytes)
KEFC.xlsx (13.3 KB)
_Test.xaml (13.0 KB)

Thanks in advance.

Hi Yoichi,

Issue resolve also for excel datatable.
This is final code:
Dim d As Decimal
Dim e As Int32
var_KEFC_DT.AsEnumerable.ToList.ForEach(Sub(r)
var_KEFC_DT.Columns.Cast(Of DataColumn).ToList.ForEach( Sub(c)

If (Decimal.TryParse(r(c).ToString,d) AndAlso d <> 0 AndAlso d.ToString.Length>10) Then
r(c)=System.Text.RegularExpressions.Regex.Replace(d.ToString,"[1]+",Function(m) Math.Round(Double.Parse(m.Value),5,MidpointRounding.AwayFromZero).ToString)

ElseIf(Convert.ToString(r(c)).Contains(“E-”) AndAlso Convert.ToString(r(c)).Length>10)
Console.WriteLine(r(c).toString)
r(c)=System.Text.RegularExpressions.Regex.Replace(r(c).ToString,"[2]+",Function(m) Math.Round(Double.Parse(m.Value),5,MidpointRounding.AwayFromZero).ToString)
Console.WriteLine(r(c).toString)
End If
End Sub
)
End Sub
)


  1. ^Ee ↩︎

  2. ^Ee ↩︎

Hi,

FYI, Turning on Preserve Format property of ReadRange might solve your problem, too.

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.