I have an API web http://www.boredapi.com/api/activity/ which randomly creates an activity to do if you are bored. The common output is the activity with the followings fields: key,link,participants,accessibility,price and type.
I'm only interested in showing the activity, the type and the price.
So far so good.
BUT, I wan to be able to get only the activities that are WITHIN a range of prices.
I created the function "fun" and has two parameters (the minimum price and the maximum we are willing to pay.
I want to check in a range from 0 to 10 which activities are available in a specific range of price.
The only thing I can't get around is how to tell the API to print only if the activities are in these ranges...
I tried to access the attribute with ['price'] but it doesn't seem to make any difference.
How would you address this issue?
Currently the output is something like this, the only issue is the price range
import requests
import json
def fun(minprice,maxprice):
for i in range(0,10):
response= requests.get("http://www.boredapi.com/api/activity/")
content_dict=json.loads(response.content)
del(content_dict['key'])
del(content_dict['link'])
del(content_dict['participants'])
del(content_dict['accessibility'])
minprice=content_dict['price']
maxprice=content_dict['price']
print(content_dict)
fun(0,0.1)
Hello from what I understand you are trying to go though each option and check if the price is between two values you can do this by check if the price is between your values like this assuming that content_dict['price'] is a float
if content_dict['price'] > minprice and content_dict['price'] < maxprice:
# whatever you want
Related
I was trying to enable multi-select for Owner in Employee Time Activities and wanted to try based on below article.
https://asiablog.acumatica.com/2018/01/multi-select-selector.html
Then override view like below:
https://asiablog.acumatica.com/2017/11/sql-in-operator-in-bql.html
However, after I added ValidateValue = false in field:
I am getting this error.
I looked at the custom attribute and I don't think it could be replaced with anything keeping the same implementation.
So, is there any other way I can accomplish multi select feature to allow display Employee Time Activities for selected employees at once besides the ideas mentioned above?
Thanks.
Your primary issue is that DimensionSelector is different than Selector.
Secondary thing to keep in mind that when you do Multiselector you would need to update the field that holds the values to have a longer length. The way a multiselector works is that it stored the saved values as a ; (semicolon) separated string. so if the field was 10 long you would want to expand to whatever you expect the max number of selected values would be, e.g. 40 would be 480, 40x10 + 40x2, 10 being the original size, 2 being a semicolon and space. (hope that makes sense :) )
Next you would have to update all the functional business logic to then parse that string and loop each, in this case, employee for the functions.
I am speaking very generically here. So not sure what you're actually attempting to do here, but one would assume that if you were selecting multiple employees you would want records to reflect accordingly.
Like the title says, I'm trying to sum elapsed time based on two criteria in Excel (2016). Specifically the elapsed time of a phone call based on user and call type, examples below.
The actual data is similar to this Dummy Data Set where there would be a list of users, Full name, the duration of a given call, Duration, and the type of call, Call Type.
The expected output would be in this format; however, the main focus for my issue falls under the Total Time column, and its worth noting that the red times shown were hand-done as these are the cause of this post.
As for the logic I'm using at the moment to try and get these results, it's =SUMIFS(C2:C16, B2:B16, G2, D2:D16, H2&"*") where C2"C16 is the Duration column, B2:B16 is the Full Name column, G2 is "Generic User", D2:D16 is Call Type, and H2&"" comes to Local, worth a note is the wildcard, as there are two types of Internal and Local calls, but I'm just trying to get all Local and all Internal without distinction of sub-types.
Additional notes for the cell formats are that the Duration and Total Time columns are set for [h]:mm:ss, but I've also tried other time and number formats which didn't change the outcome.
So at this point I'm just spinning my wheels as I've Googled and looked into different ways to go about this, such as different cell formats, cell operations/logic and so on, and I'm just unsure where the issue may actually be, so any suggestions or help would be very appreciated.
Edit 1: Including a link for the file
J2 This is for your reference only.
=SUMPRODUCT((B$2:B$16=G$2)*(C$2:C$16)*ISNUMBER(FIND(H2,D$2:D$16)))
When I wanted to get the median price of an item on the steam market I came across this answer. It gets the lowest and median price of an item. The one thing I had trouble understanding which currency number corresponds with what currency and if so, which industry standard is used here.
This is an example URL:
https://steamcommunity.com/market/priceoverview/?appid=730¤cy=3&market_hash_name=Tec-9%20%7C%20VariCamo%20(Minimal%20Wear)
In the documentation it says it is ISO 4217:
An optional ISO 4217 currency code. If specified, only prices for this currency need to be
But that's clearly not the case.
When I put in 1 as the currency parameter, I get dollar.
With 2 I get pounds.
And with 3 it responds with euro.
...
The max seems to be 41 with the Uruguayan Peso
All actual currency codes and other respective information about currencies on Steam can be found in global.js on https://steamcommunity.com/market/. Just open this page. Then open developer console and search for g_rgCurrencyData variable like on image below.
Location of g_rgCurrencyData variable
Besides codes there are info about formatting for each currency which is useful when you need to parse data from page or automate some actions.
I am using Really Simple Traffic Logger to store Date, Timestamp, IP and visited site by users on my website. Each user visiting the website is assigned a UID by a parameter in the URL in the form of:
http://www.domain.com/site.php?=dTM_c1_uid7
dTM = customer,
c1 = category 1,
uid7 = uid for person 7
The csv file stored contains the following:
"DATE","TIME","IP","LOOKING_FOR"
"2016-05-22","07:30:40","XX.XX.XX.XX","/site.php?=dTM_c1_uid7"
"2016-05-22","07:31:10","XX.XX.XX.XX","/site.php?=dTM_c1_uid7"
"2016-05-22","07:31:19","XX.XX.XX.XX","/site.php?=dTM_c1_uid8"
the information is stored in a CSV-file, where I am attempting to sum the results of the data, which is to be visualized by another script in real-time. However, as many of the visitors are the same people visiting the website more than once, I would like to remove these based on the UID parameter in the URL, before calculating the sum, so each count (hit) can be calculated as unique hits.
I am therefore trying to work out a formula for auto-removing duplicates that contains the "_uid7" parameter, before calculating the sum.
Is there a smart method for constructing a formula in excel that can do that automatically?
Thank you.
Supposing your data starts from A1 Please post the following formula in B1and fill down the column B with data in column A
=TRIM(SUBSTITUTE(MID(A1,(SEARCH("dTM_c1_",A1,1)+7),99),CHAR(34),REPT(CHAR(32),99)))
You will get uid7, uid8 etc which can be counted or other processing can be done.
EDIT
Based on your comments and taking "dTM_c1_uidnn.." string counts of occurrence is shown in the following snapshots. I have shown two snap shots out of which one hides the helper column.
This is the best I could do at the moment. Column B can be filtered either with Excel native Remove Duplicates OR by a VBA routine. Finding unique values of numerical values is comparatively easy using Frequency Function But somehow after repeated attempts despite following some tutorials, I could not get the desired results for text strings. I would appreciate your feedback positive or negative. My efforts would continue to find the most optimal solution.
In python, using libs to work with excel files, I could do what I want.
But now, because I'm trying to learn VBA, I need to ask this question.
I'm working on a worksheet that has around 12 columns, and 50000 rows.
This data represents Requests sent to the company.
The 5# column represents its code, 10# the time took to finish it.
But, for example, rows 5, 10 and 12 could belong to the same Request, and was just divided for organizational purposes.
I need to treat these data, so that I can:
Column 6# represent the person
who answered the request. So, I need
to put each request on the "person's
worksheet". Also, create this
worksheet for him before starting to
add requests to it.
For each person (worksheet),
contabilize request types (Column
2#) attended by him. I.e., create
another table on its worksheet
showing:
Type_Of_Request | Number_of_ocurrences
Create a final Report Worksheet, showing the same table
above, but accounting all requests
(without person filter)
Obs: I know that most questions on stackoverflow are to solve a specific question, but I'm asking for start routes here.
Or even solutions, if possible.
For explanation purposes, I think that explaining the algorithm used in python will help persons who know a little of python and VBA to help me here.
So, for each issue:
Create a dict that manages the 6# column data.
This dict will have the person's unique name as the key, and for each request that him answered, it will be added to a list pointed to his name (the dict key).
Something like:
{person1: [request1, request2, request3, ...], ... }
Another dict that manages the 2# column data (the request type).
Now, I will have a dict where each entry will have a list showing requests that are of that type.
After positioning all requests, I did a simple sum on the list, and filled a table with (key, sum(dict[key]))
where dict[key] is the list of requests of same type, and a sum on it returns the total of requests of that type.
Something like:
{request_type1: [request1, request2, request3, ...], ... }
Well, same of 2, but applying the algorithm on the initial complete table.
I don't know if VB has a dict type like python has (and helps a lot!), even because I'm new on VB.
Thanks, a lot, for any help.
vba does indeed have a dictionary type, but it's usage may not mirror python's implementation. (see: http://msdn.microsoft.com/en-us/library/aa164502%28v=office.10%29.aspx )
you can also create a user defined type ( see: http://msdn.microsoft.com/en-us/library/aa189637%28v=office.10%29.aspx )
If you have a working solution, that is your best jumping-off point. Many of the python string function etc are probably even named the same or close enough for you to easily find them in the language reference.
You may find this easier with ADO, which works quite well with Excel using the Jet/ACE connection. It also will allow to use rs.CopyFromRecordset to write suitable sets to worksheets.