Conversion de dato

Hola!
necesito su ayuda!
tengo un dato el cual lo extraigo desde un pdf, con extract document data.
he intentado de varias maneras pero no funciona, o lo convierte directamente a 4, necesito que solo muestre 3700, no quiero que muestre 3.700,00.

image

si me ayudaran con eso se los agradecería!

help

Hi @mively

¿Podrías probar lo siguiente?

Math.Round(Convert.ToDecimal(inputString, System.Globalization.CultureInfo.GetCultureInfo("de-DE")), 0).ToString

Explicación:
Suponiendo que “ExtractionOutput.Data.Price.Value” es una cadena. El código lo convertirá al formato decimal universal desde el formato DE. Luego lo redondeamos y lo convertimos de nuevo en cadena.

El resultado:

Si esto resuelve su problema, márquelo como una solución.
Feliz automatización :star_struck:

Hi @mively

Try
extractedText = “3,700.00”
cleanedText = extractedText.Replace(“,”, “”) - Elimina las comas
cleanedText = Convert.ToDecimal(cleanedText).ToString(“F0”) - Elimina los decimales, mantiene como entero

Resultado: cleanedText = “3700”

Si te fue útil, ¡siéntete libre de marcarlo como solución!

@mively

based on your output you can try this simple logic, i hope it may help you

CInt(strInput.Replace(“.”, “”).Replace(“,”, “.”))

Happy Automation!!

si pense en eso, pero el resultado de la variable es dinamica, va cambiando

¿Podrías probar mi solución?

Sorry

you are talking about my solution or others,
you replied to my post and in reply there other post..

¿Podrías probar mi solución?

Funcionará para cualquier número en el formato DE

También puedes usar

CInt(Convert.ToDecimal(inputString, System.Globalization.CultureInfo.GetCultureInfo("de-DE"))).ToString

1 Like

me a servido, en parte.
me aparece este error…

image

mi duda es, lo guarda como moneda, no entiendo por que, puedo hacer algo para solucionar esto?

CInt(Convert.ToDecimal(inputString.Replace(“$”,“”), System.Globalization.CultureInfo.GetCultureInfo(“de-DE”))).ToString

1 Like

me aparece ese error, lo intente hacer en un assig y escribir directamente en el input de
write cell

1 Like

Do the inputString.Replace(“$”,“”) separately and then do the CInt(Convert.ToDecimal(inputString, System.Globalization.CultureInfo.GetCultureInfo(“de-DE”))).ToString

@mively

you can use regular expressions to first remove the currency sign and then eliminate the decimal part. You can use Regex.Replace to remove any leading currency symbols (like $, , £, etc.) with the pattern ^[^\d]+ and then convert the result to a number using Math.Floor or CInt.
Try this
myNumber = System.Text.RegularExpressions.Regex.Replace(myNumber, “[1]+”, “”)
myNumber = Math.Floor(CDbl(myNumber))


  1. ^\d ↩︎

1 Like

disculpa,
mi variable principal es ExtractionOutput.Data.Price.Value

quiza por eso me sigue dando error, por el tipo de dato, he hecho lo que me dices pero no

help

@mively

Make sure to treat ExtractionOutput.Data.Price.Value as a string before performing the replacement and splitting. This should resolve any issues related to data types and allow you to clean and write the value correctly.
@mively
first use an Assign activity to clean the value and store it in a variable, like this:

cleanedValue = extractedValue.Replace(“$”, “”).Replace(“,”, “”).Split("."c)(0)

Then, in the Write Cell activity, use the variable cleanedValue as the value to write to the cell. This avoids directly writing the expression in the Write Cell input.

If You found helpful, feel free to mark as a solution!

Hi @mively

It is not because of that.

Don’t use assign activity. Use Invoke Code instead. It will work:



The Invoke code executes without the compilation Error:

Assign throws error:

Is “ExtractionOutput.Data.Price.Value” a String? could you check in Locals panel

Could replace inputString with ExtractionOutput.Data.Price(0).ToString

2 Likes