I'm a newbie programmer using python and I need help badly. I have a large FDF form that I need to populate and the entry field list is in a txt file which I read into a (my)list.
mylist = {'NAME', 'ADDRESS', 'PHONE', ....}
Is there a way to create variables to each of the element in my list and assign values to them. Like I want to assign:
NAME = 'John Doe'
ADDRESS = '99 Elm Street'
PHONE = '555-364-1234'
Appreciate any help!
If you are asking what I think you are asking, perhaps what you want isn't a list, but a dictionary.
Here's more info:
https://www.tutorialspoint.com/python/python_dictionary.htm
Related
I Have a number of InputListBox's in an iLogic rule that use information from an ArrayList to create an iProperty name and value. This works but the selection list is somewhat bunched together where as an InputRadioBox is much easier not only to read but select from.
My question - is it possible to use an existing ArrayList or to make a List in my rule that an InputRadioBox can use?
My ArrayList's are generally as long as 25 item's, I've tried multiple way's to use my existing ArrayList's to no avail. See below A picture of the InputRadioBox I was able to create along with the code which does not use a list of any kind.
BooleanParam = WCList
WCList = InputRadioBox("Add A WorkCenter", "WC A01 Enginner | Brent" ,"WC C02 Laser/Punch",WCList, Title := "Select Work Center")
I need to have a script which can copy the value from InternetAddress Field in the person document one by one in names.nsf and append it in the User Name field. Can someone help with a working script?
This can literally be done with a one-line formula, using a simple assignment statement and the list append operator. It is really the most basic thing you can do in all of Lotus Notes programming. It doesn't even need to use any of the #functions.
The syntax for an assignment is:
FIELD fieldThatYouWantToSet := value;
The syntax for the list append operator is:
value1 : value2;
The only other thing you need to know is that value1 and value2 can simply be the names of existing items (a.k.a. fields), and the list of values in the second item will be appended to the list of values in the first item.
Then, all you will need to do is to put this one-liner into a formula agent that runs against all documents in the current view, and run the agent from the Actions menu while you are in the view.
Option-1:
There are a few ways to accomplish this, the simplest being , as the user specified before, a simple field function would do.
FIELD UserName := UserNAme:InternetAddress;
You could set and run the above field function in an agent in $UsersView
In option-2, you could also use the "UnProcessedDoc" feature and set and run as an agent.
But, here, I have written one another way to set and run as an agent in $UsersView.
Hope this helps, please approve this answer if this had helped anyone.
Option:2
At present , no Domino in my System, in order to test this snippet. I wish there exists any method online to test this snippet before I post.
But, logically, consider this snippet as a pseudo-code to accomplish ur objective.
Above all, it has been more than a decade or two ever since I have programmed in Domino. Because, I moved on to RDMS, DW, BI and now to Cloud... well Cloud-9. :)
Here is a portion of lotus script code to copy the value from InternetAddress Field in the person document one by one in names.nsf and append it in the UserName field.
Dim db As New NotesDatabase( "Names Db", "names.nsf" )
Dim view As NotesView
Dim doc As NotesDocument
Dim InternetAddress_value As Variant
Set view = db.GetView( "$Users" )
// loop thru all docs in $Users view.
// Get InternetAddress_value and rep it in UserName
Set doc = view.GetFirstDocument
If doc.HasItem("InternetAddress") Then
While Not(doc Is Nothing)
// in this line we concatenate username with IAaddress_value
new_value= doc.GetItemValue( "username" ) + doc.GetItemValue( "InternetAddress" )
Call doc.ReplaceItemValue( "UserName", new_value)
Call doc.Save( False, True )
Set doc = view.GetNextDocument(doc)
Wend
End If
This solution is posted by Mangai#Notes#Domino#Now_HCL . Encourage to post more solutions by approving the answer.
in django admin we have search field at the top of the page (right?).
If I take example of user model. and search field is there.
search_fields = ('name', 'phone', 'email', 'city')
I get a query_param in GET api. but my program doesn't know what it is. it could be a phone_no or email or name or anything else. I have to search in User model and filter out all rows which contain this data in any of the column.
so I want to write a django query but I'm not sure what is the best optimized way to do this.
write now I use Q object and then OR operation.
e.g. Q(phone=param) | Q(email=param) .
and Iwant to know if i have to write SQL query for this how would I
Q object is definitely right. You could do it dynamically like:
from django.db.models import Q
search_fields = ('name', 'phone', 'email', 'city')
q_objs = [Q(**{'%s' % i: param}) for i in search_fields]
queries = reduce(lambda x, y: x | y, q_objs)
results = Model.objects.filter(queries)
You can even do q_objs = [Q(**{'%s__icontains' % i: param}) for i in search_fields] to support incomplete search.
With ORM you can do no more than chain Q objects. You can try to write your own SQL queries but there is much work to do and you won't accomplish the best possible search also.
If you really want to have fast search that will deal with big amounts of data you need to take a look at haystack. It's a very good django module which makes search easy and fast.
Here is an example of what I am trying to do:
def famlist = selection.getUnique('Family_code')
... Where “””...
and testedWaferPass.family_code in $famlist
“””...
famlist is a list of objects
‘selection’ will change every run, so the list is always changing.
I want to return only columns from my SQL search where the row is found in the list that I have created.
I realize it is supposed to look like: in ('foo','bar')
But no matter what I do, my list will not get like that. So I have to turn my list into a string?
('\${famlist.join("', '")}')
Ive tried the above, idk. Wasn’t working for me. Just thought I would throw that in there. Would love some suggestions. Thanks.
I am willing to bet there is a Groovier way to implement this than shown below - but this works. Here's the important part of my sample script. nameList original contains the string names. Need to quote each entry in the list, then string the [ and ] from the toString result. I tried passing as prepared statement but for that you need to dynamically create the string for the ? for each element in the list. This quick-hack doesn't use a prepared statement.
def nameList = ['Reports', 'Customer', 'Associates']
def nameListString = nameList.collect{"'${it}'"}.toString().substring(1)
nameListString = nameListString.substring(0, nameListString.length()-1)
String stmt = "select * from action_group_i18n where name in ( $nameListString)"
db.eachRow( stmt ) { row ->
println "$row.action_group_id, $row.language, $row.name"
}
Hope this helps!
CHtml::dropDownList('name','select',$listData,$htmlOptions);
Everything is OK until I faced one issue. I've got an array, which looks like this:
array(
array('ua', 'Ukraine', '380'),
array('ru', 'Russia', '7'),
...
array('kz', 'Kazakhstan', '7'),
);
$listData is an array of (value=>label). First I walked through array and made (code=>country) array as $listData. But I found that different countries may have the same code. I can use first "two letter geo" as key, and $listData will be an unique array.
And what if I need the same value but under different labels?
It seems that the only Yii solution is to concatenate labels under one key(value).
Or use pure html and echo each option separate.
I think the sensible way to do this is with a new model, with a new id (INTEGER PRIMARY KEY AUTOINCREMENT), and hold the data in separate fields (country, geo, code.)
Create your listdata to be an array using only the new id and the country so the array looks something like this:
array( 0=>'Ukraine', 1=>'Russia', 2=>'Kazakhstan' );
This way you will only send the id, and figure out the data (geo, code, country) on the receiver side.
But I must ask about this:
It seems that the only Yii solution is to concatenate labels under one key(value).
How do you want a option-tag to look like exactly?
<option value="ua" code="380">Ukraine</option> // Like this?
Then you should set htmlOptions similar to this:
array(
'ua'=>array('code'=>'380'),
'ru'=>array('code'=>'7'),
...
);