How to achieve below using Abinitio component? - ab-initio

My Input is something like below:
fieldname
Anusha
My requirement to get the output as follows:
fieldname
A An Anu Anus Anush Anusha

GDE 4.x
One of the way: to use 'Transform/Reformat' (Transform/Reformat recordset) component.
Inside Transform/Reformat Component, you have to use String function to split Input data to data you need..
Did you asked AbInitio support about it?

If that is true then
Use normalize component
Specify the length as string_lenght(in.field_name);
and in normalize function write as
out.field_name :: string_substring(in.field_name,1,index);

This should work:
out::reformat(in)=
begin
out.str :: funny_string(in.str);
end;
out :: funny_string(str) =
begin
let int i;
let string("\n") s="";
for(i,i<length_of(str))
s = s + " "+string_substring(str,1,i+1);
out :: s;
end;

Related

Databricks: calling widget value in query

I've created a widget called yrmo with the values such as 202001.
I need to call this value from a query but it doesn't recognize it, I think because the field I am applying it to is Int but I can only reference the widget with quotes around it.
If I don't use quotes then it thinks I'm using a field in the table. If I use single quote then it interprets it as a literal. I've tried getArugument but it says it doesn't recognize it (do I load something?)
The query is is scala.
val x = sqlContext.sql("select domain from TABLENAME where partsn_mo=yrmo)")
Thanks
You can use Scala's string interpolation with an expression inside of ${} that may include double quotes.
So you could do:
val x = spark.sql(s"select domain from TABLENAME where partsn_mo = ${dbutils.widgets.get("yrmo")}")
Try doing this
val query = "select domain from TABLENAME where partsn_mo=" + dbutils.widgets.get("yrmo")
val x = sqlContext.sql(query)

How to get the variable a function is assigned to?

I need to get the variable a function's return value is assigned to.
function example()
end
variable = 3 --just for example
variable = example() --I need the value of variable(in this case 3) passed as an argument to example()
Please read the Lua reference on how to call and define functions.
https://www.lua.org/manual/5.3/manual.html#3.4.10
https://www.lua.org/manual/5.3/manual.html#3.4.11
You can simply do this:
function fancyFunction(val)
return val
end
local val = 3
val = fancyFunction(val)
of course this minimum example does not make much sense. You should of course have another return value than your argument. Otherwise you don't have to call the function in the first place.
(Quite hard to understand what you're trying to do.) Could you possibly be referring to object oriented programming? If so, then you need something like this:
--setup
t = {}
function t:set(v) self.value = v end --assign value to 'variable'
function t:get() return self.value end
--use
t:set(3)
print(t:get())

In Delphi using MyDAC, how do I write an entire record as a string?

As the title suggests, using Delphi 2010 and MyDAC 7.1, how do I output an entire string as a string like JSON / XML / CSV or some other plain text option?
eg output:
{user_id:1;username:testuser;password:testpass}
Presuming that MyDAC is a standard TDataSet descendant, you can build the string manually. For instance, for JSON:
var
i: Integer;
Output: string;
begin
Output := '{'; // #123;
for i := 0 to MyQry.FieldCount - 1 do
Output := Output +
MyQry.Fields[i].FieldName + ':' + // #58
MyQry.Fields[i].AsString + ';'; // #59
// Replace final ; with closing } instead
Output[Length(Output)] := '}'; // #125
end;
Or you can Google to find a Delphi JSON library (like SuperObject) and use it instead, as is done here.
For XML, use the same type loop with TXMLDocument. You can search for previous posts here tagged with Delphi to find examples.
For CSV, it can get complicated based on your data and the requirements. For instance, do you want or need a header row with field names? Does your data contain data that contains spaces or punctuation or CR/LFs? The easiest solution is to search for an already-existing library (via Google or Bing, not here) that exports to CSV.
According to the documentation you can use the SaveToXML procedures. should be something like this:
var
MyQuery: TMyQuery;
begin
try
MyQuery := TMyQuery.Create();
MyQuery.Connection := AConnection;
MyQuery.SQL.Text := ACommand;
MyQuery.Execute();
MyQuery.SaveToXML(<tstream or file>)
except
raise;
end;
end;

Can i convert a string into a method?

Ok if you don't under stand the title, let me example.
lets say I have a variable called "money" which is in class "wallet". Normally I would just do this to get the value;
trace(wallet.money);
but if I had 10 different money variables like money_1 , money_2 etc...
so can i make a string which original value as "wallet.money_" then just add the number at the end. so the function would look like this
public function getmoney(num:Number):Number
{
var word:String = "wallet.money_" + num.toString();
return // this would be where i return the value of the money variable.
}
is this possible or not?
You can reference it like this:
wallet["money_" + i]
i is an int - use int for index number not Number.

how to replace a certain value in string?

I am using Flexbuilder with sdk 3.5. I convert an int to a binary string. Now I want to replace binary value at certain index. How can I do this?
I tried following but it did not work;
binaryStr[0] = "0";
and
binaryStr[0] = '0';
You could use String.split() to convert your String into an Array, then change what you want, and finally convert the resulting Array into a String with Array.join() ?