I have to present my RowCount as a zero filled string. My variables are
RecordCount data type integer and StringRecordCount data type String. My Expression Task is
#[User::StringRecordCount] =
#[User::RecordCount] < 10 ? "00000" + (DT_STR,1,1252) #[User::RecordCount] :
#[User::RecordCount] < 100 ? "0000" + (DT_STR,2,1252) #[User::RecordCount] :
#[User::RecordCount] < 1000 ? "000" + (DT_STR,3,1252) #[User::RecordCount] :
#[User::RecordCount] < 10000 ? "00" + (DT_STR,4,1252) #[User::RecordCount] :
#[User::RecordCount] < 100000 ? "0" + (DT_STR,5,1252) #[User::RecordCount] :
(DT_STR,6,1252) #[User::RecordCount]
The Expression Task likes it but when I try to run the package I get the error "A truncation occurred during evaluation of the expression."
I don't know why. Can somebody help?
Thanks,
Dick
I figured out a workaround. I used the same code (with the exception of the #[User::StringRecordCount]), put it into a Derived Column and wrapped the whole thing in a (DT_STR,6,1252). Worked perfectly.
Thanks,
Dick
Related
i have this ugly noob func:
def run_prog(compile_container, user_input, container_file_path):
# bash doesnt support single quotes or quotes inside double quotes so ## = '
time_check_command = '/usr/bin/time -f "## , ##memory##:##%M## , ##time##:##%e##"'
result = compile_container.exec_run(
f"/bin/bash -c 'echo {user_input} | {time_check_command} ./a.out'",
workdir=container_file_path)[1].decode('utf-8')
result = '{"result":"' + result + ',}'
result = result.replace('##', '"')
result_dict = json.loads(result)
if result_dict['time'] == '0.00':
result_dict['time'] = '<0.01'
return result_dict
Most of time it retrun json like this:
{
"result": "888",
"memory": "1792",
"time": "<0.01"
}
But one time of 10 or mb 20 it raise an error "error json.decoder.JSONDecodeError: Expecting ','" and i dont know why. Same input always. Can u please tell what is wrong?
So, i dont really sure whats wrong, but switch from json.loads to ast.literal_eval helped.
result_dict = ast.literal_eval(result)
I have a Flag which needs to be set to 1 or 0. so i used Derived column transformation to convert it to bool
as you can se the code it works only when i use an OR operator for both Y and N .
This code below works for IF Flag is Y and N condition
(DT_BOOL)(Flag == "Y" ? 1 : 0) || (DT_BOOL)(Flag == "N" ? 0 : 1)
** working only when FLAG = (Capital)Y OR N *****************
but if my Flag is small 'n' it does not work it still sets to TRUE
I want to make it UPPER and TRIM it at the same time . Which i am having hard time to figure out .
This is my code but it does not work
(DT_BOOL)(UPPER(RTRIM(LTRIM
(Flag == "Y" ? 1 : 0)
)))
||(DT_BOOL)(UPPER(RTRIM(LTRIM(Flag == "N" ? 0 :1)
))) ***** this code is not working *****************
Thanks for your time.
PLEASE look at Tranformation Pic
Try this...
(DT_BOOL)(UPPER(RTRIM(LTRIM(Flag))) == "N" ? 0 :1)
Does anyone know how to access specific outputs of the Dymola built-in function getExperiment();?
Unfortunately it only returns the Real scalar StartTime.
The function seems to be defined as follows:
function getExperiment "Get current experiment setting"
output Real StartTime := 0.0 "Start of simulation";
output Real StopTime := 1.0 "End of simulation";
output Integer NumberOfIntervals := 0 "Number of output points";
output Real OutputInterval := 0.0 "Distance between output points";
output String Algorithm := "" "Integration method";
output Real Tolerance := 0.0001 "Tolerance of integration";
output Real FixedStepSize := 0.0 "Fixed step size for Euler";
end getExperiment;
My test model is:
model GetExpTest
Real staTime;
Real outInterval;
equation
(staTime,outInterval)=receiveInfo();
end GetExpTest;code here
With the function:
function receiveInfo
output Real startT;
output Real outputInterv;
algorithm
(startT,,,outputInterv,,,):=getExperiment();
end receiveInfo;
And the error message I get is:
Compiling and linking the model (Visual C++).
dsmodel.c
dsmodel.c(32) : error C2079: 'dummy_mult_' uses undefined struct 'getExperiment_struct'
dsmodel.c(32) : warning C4013: 'getExperiment' undefined; assuming extern returning int
dsmodel.c(33) : error C2224: left of '.StartTime0_0_0member' must have struct/union type
dsmodel.c(34) : error C2224: left of '.OutputInterval0_0_0member' must have struct/union type
Error generating Dymosim.
Thank you in Advance for help!
If I do: getExperiment(), the following is returned:
= 0.0, 1.0, 500, 0.0, "dassl", 0.0001, 0.0
So you can access the values using a regular assignment taking multiple outputs. For example:
(StartTime,,NumberOfIntervals) := getExperiment()
Which returns:
Declaring variable: Real StartTime ;
Declaring variable: Integer NumberOfIntervals ;
StartTime
= 0.0
NumberOfIntervals
= 500
Below are the strings representing date of birth (yymmdd). I want to convert it into datetime format and load into a database using ssis. How can I do it? In my derived column I have (DT_DATE)(SUBSTRING([Drv DOB],1,2) + "-" + SUBSTRING([Drv DOB],3,2) + "-" + SUBSTRING([Drv DOB],5,2)), but it's not working.
I GET THESE ERRORS:
[Derived Column [2]] Error: An error occurred while attempting to perform a type cast.
[Derived Column [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Derived Column" failed because error code 0xC0049064 occurred, and the error row disposition on "Derived Column.Inputs[Derived Column Input].Columns[Drv DOB]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
•470324
•470324
•470209
•101
•0
YEAR have 4 digits not 2, so it would be:
(DT_DATE)("20" + SUBSTRING([Drv DOB],1,2) + "-" +
SUBSTRING([Drv DOB],3,2) + "-" +
SUBSTRING([Drv DOB],5,2))
This works for me! Thanks everyone
([Drv DOB] == "0") || ([Drv DOB] == "101") ? NULL(DT_DBTIMESTAMP) : (DT_DBTIMESTAMP)(SUBSTRING([Drv DOB],1,2) + "-" + SUBSTRING([Drv DOB],3,2) + "-" + SUBSTRING([Drv DOB],5,2))
Using SQL Server 2008, Visual Studio 2008.
Trying to convert the data from a string column into a derived Date column.
The string can be in two formats, either : "dd/mm/yy" (where century 20 can be assumed), or "dd/mm/yyyy" . e.g. "02/05/12", "23/12/02", "13/08/2012".
So I tried an expression like this for a Derived column :
DateReceived == "" ? NULL(DT_DATE) : (DT_DATE)((LEN(RTRIM(DT_DATE)) == 10 ? SUBSTRING(DateReceived,7,4) : ("20" + SUBSTRING(DateReceived,7,2))) + "-" + SUBSTRING(DateReceived,4,2) + "-" + SUBSTRING(DateReceived,1,2))
but Visual Studio gives error :
"The expression was not valid, or there is an out-of-memory error".
It accepts a simpler expression like :
DateReceived == "" ? NULL(DT_DATE) : (DT_DATE)("20" + SUBSTRING(DateReceived,7,2) + "-" + SUBSTRING(DateReceived,4,2) + "-" + SUBSTRING(DateReceived,1,2))
but this expression will only work for "dd/mm/yy" format.
What am I doing wrong ? Thanks.
Never mind, the error was due to a typo. (Was calling RTRIM on the column type, not column name).
The following works :
DateReceived == "" ? NULL(DT_DATE) : (DT_DATE)((LEN(RTRIM(DateReceived)) == 10 ? SUBSTRING(DateReceived,7,4) : ("20" + SUBSTRING(DateReceived,7,2))) + "-" + SUBSTRING(DateReceived,4,2) + "-" + SUBSTRING(DateReceived,1,2))