I have been trying to do a datatype check in a decimal column of a file by using the Data Flow from Azure Data Factory, but it is not working as expected. My issue is the following one:
I want to check if the number 121012132.12 is a decimal, so I am using the data flow's derived column and writing the expression: isDecimal('121012132.12', '17.2'). The output has always been false, even if I change the precision or replace a dot with a comma, etc. I have tried many different ways, but without success. I realized that if I shorten the number, it recognizes it as decimal. Moreover, If I try to convert it into decimal, it works well (toDecimal('121012132.12', 17, 2)
Please, can anyone tell me if there is a different way to do this check?
Thank you in advance
This happens because for decimal the precision is defaulted to (10,2).
try isFloat('121012132.12') this will work
Thanks
Hijesh
Related
I have some complicated array of structures and I want to write it into CSV file. So I need "variable to string" conversion.
Beckhoff as always doesn't care about documentation and their INT_TO_STRING function doesn't work (UNEXPECTED INT_TO_STRING TOKEN when I try to write INT_TO_STRING(20) ).
Moreover their string functions works correctly with only 255 chars.
So I need one of following:
working functions or function blocks or library which allows to convert different types to string
something like sprintf without limitations
some functions to convert between number and ascii char (0x55 is letter 'U') in both directions.
btw. Beckhoff gives us some weird CSV example code, but without data conversion (array has already strings in cells).
Thanks in advance!
I tried to use:
INT_TO_STRING() BYTE_TO_STRING() WHATEVER_TO_STRING()
but it is not working. And there is no clue how many arguments it should have or anything. There is no documentation in Beckhoff information System.
I have installed the INTL Bundle for Sonata which provides a few twig helper functions for currencies.
The twig function is number_format_currency('currency_code')
If I have a value such as 2000000, I would like to be displayed as £2,000,000, currently when I run 2000000|number_format_currency('GBP') it returns £2,000,000.00 - so with a trailing 2 0s after the decimal point.
Ive dug in to a little and can see its using symfony's number formatter and it supports a few constants passed in as array, it seems to only support 'FRACTION_DIGITS', 'ROUNDING_MODE', 'GROUPING_USED'.
Out of these FRACTION_DIGITS seems to make sense to change to 0, to this I have tried:
2000000|number_format_currency('GBP',{'FRACTION_DIGITS':0})
But i'm getting the same number with the 2 decimal points at the end, i'm sure its an easy fix maybe i'm passing the array in wrong or something but its had me stumped for a little while, can anyone help?
I have a dataset with data collected from a form that contains various date and value fields. Not all fields are mandatory so blanks are possible and
in many cases expected, like a DeathDate field for a patient who is still alive.
How do I best represent these blanks in the data?
I represent DeathDate using xsd:dateTime. Blanks or empty spaces are not allowed. All of these are flagged as invalid when validating using Jena RIOT:
foo:DeathDate_1
a foo:Deathdate ;
time:inXSDDatetime " "^^xsd:dateTime .
foo:DeathDate_2
a foo:Deathdate ;
time:inXSDDatetime ""^^xsd:dateTime .
foo:DeathDate_3
a foo:Deathdate ;
time:inXSDDatetime "--"^^xsd:dateTime .
I prefer to not omit the triple because I need to know if it was blank on the source versus a conversion error during construction of my RDF.
What is the best way to code these missing values?
You should represent this by just omitting the triple. That's the meaning of a triple that's "not present": it's information that is (currently) unknown.
Alternatively, you can choose to give it the value "unknown"^^xsd:string when there's no death date. The solution in this case is to not datatype it as an xsd:dateTime, but just as a simple string. It doesn't have to be a string of course, you could use any kind of "special" value for this, e.g. a boolean false - just as long as it's a valid literal value that you can distinguish from actual death dates. This will solve the parsing problem, but IMHO if you do this, you are setting yourself up for headaches in processing the data further down the line (because you will need to ask queries over this data, and they will have to take two different types of values into account, plus the possibility that the field is missing).
I prefer to not omit the triple because I need to know if it was blank
on the source versus a conversion error during construction of my RDF.
This sounds like an XY problem. If there are conversion errors, your application should signal that in another way, e.g. by logging an error. You shouldn't try to solve this by "corrupting" your data.
How would I go about reading in an input that looks like "01/12/1997" to 3 seperate integers that are 01, 12, and 1997?
If using GNAT, you can use GNAT.String_Split, followed by the 'Value attribute conversion.
And just in case your question was an intermediate step on the way to parsing dates, you should take a look at GNAT.Calendar.Time_IO.Value which knows about parsing various dates formats.
I ended up adding 3 more variables, all strings. I then set them as Date(1..2) and Month(4..5) and Year(7..10), then I converted them all to integers and continued my program. Not the best way, but it worked.
I have a little Problem in Blitzmax.
I try to read an INI-file and if I read floats they are converted in a very strange way.
The line in the file which is concerned looks like that for example:
_fStrength=40.6
The Output of this looks like that:
DebugLog:_fStrength: 40.5999985
The code I use to read that works with reflection and looks like that:
For Local fld:TField = EachIn id.EnumFields()
fld.Set(obj, SearchInFile("TempWeapon" + index, fld.Name(), "Weapons.ini"))
DebugLog(fld.Name() + ": " + String(fld.Get(obj)))
Next
I found out, that this only happens if the number after the "." does not equal's 5 or 0.
I can't explain this behaviour, because if I do not use reflections, it works fine.
Could anyone help me please?
As you probably know, your computer stores numbers in binary code, using a limited size. 40.6 expanded in binary is a periodic sequence (101000.1001100110011001100..., infinitely), similarly to what happens when you try to write down the digits of 1/3) repeating and thus can not be represented exactly, so you get rounding errors.
The number of correct digits you get here looks like you are using single-precision floating point numbers, you can push the error further back by going to double, but it won't disappear.
As a reference, you might find Wikipedia on floating point helpful.