I was making a discord bot and I want to make an account system, what my program supposed to do is to keep on finding a registered user by checking on the .json file over and over until it finds the two variable with the same value, problem is I can't find anything online for a solution. I just need a code for it :)
Sure! Try something like this:
with open('filenamehere', 'r') as f:
# Add Code to add values to a list called x here
After this, we can go ahead and do one of two things:
Run a simple if value is in list x, or
Run a for loop on the list until it reaches the value required.
Either way should give you the desired outcome. Sorry I was a little vague, your question was as well.
Related
I have found two questions, but they received answers saying to set a default: one for the file extension, and the other for the specific file name.
It feels implied by those answers that this was impossible at the time to specify language with ad hoc, file-by-file specificity.
Is it possible? If so, how do I do it?
I happened to accidentally do something like this and was trying to figure out how to undo it. RubyMine had somehow put a specific filename in the file name pattern list. This might be close enough to what this question was asking.
I'm currently learning webfocus and I'm learning about defining, but what is teaching me isn't doing a great job. An example that has been given to me is about cars. If I want to make a new field to find the difference between the retail cost and the dealer cost, they said to input
DEFINE FILE CAR
CALCULATED_DIFFERENCE/D5 = RETAIL_COST - DEALER_COST
END
What I'm confused about is what the
/D5
is there for. Is it required to define a file? Does it have to be something specific? I've researched a lot but haven't found any answers about it.
From what I understand, it joins the aliases and roots. For example the D could be short for difference. The 5 could just be a number. Without all of the example and question it's hard to say.
Here is another example http://www.hwconline.com/ibi_html/javaassist/intl/EN/help/source/topic547.htm
Section
A preceding forward slash '/' is required for all aliases and context roots. The WebFOCUS Administration Console automatically adds a forward slash if one was not entered.
I am assuming it could be a pointer. Look at the url and the / indicates like a tree node. If you want to get to a location then it's location/location/location/here
here being what your looking at. So if the /D5 is called it could mean page/page/page/Difference5 so for short it omits all of the pages and signifies the direct alias D5.
I am not entirely sure but that is what I have always thought. Look at everything dealing with locations a \ or / is always used.
I've found out what it means. The /D5 is known as formatting. It allows WebFOCUS to know what is being used in the file. The D stands for decimal, which means that if I wanted to I could format it as D/5.2 and an A stands for alphanumeric. If I were to define a file called person_last_name, I would use A/30. The number determines how much data it can hold, so 30 is all I need as a person's last name probably won't be longer than 30 characters.
Struggling to find rank values from highest to lowest, please see attached example of what I'm trying to achieve.
My current custom expression is:
Sum([ViolationAmt])
I have tried this:
Sum([ViolationAmt]) over Rank([ViolationAmt])
I've played around with the rank expressions however unable to implement...would be very grateful for some help.
Spotfire Rank Example
I need to make a lot of assumptions here because I don't know anything about your data set or really what your end goal is, so please comment back and/or provide more info in your question if I am off base.
the first assumption is that each row in your dataset represents one, for simplicity, [AccountID] with a [ViolationAmt]. I'm also guessing you want to show the top N accounts with the highest violations in a table, since that's what you've shown here.
so it sounds like you are going to need two calculated columns: one for getting the total [ViolationAmt] per account, and then another to rank them.
for the first, create a column called [TotalViolationAmt] or somesuch and use:
Sum([ViolationAmt]) OVER ([AccountID])
for the second:
Rank([TotalViolationAmt])
it will be useful to read the documentation on ranking functions if you haven't already.
you could probably combine these two into a single column with something like:
Rank(Sum([ViolationAmt]) OVER ([AccountID]))
but I haven't tested this at all. again, if you put in a bit more detail about what you're trying to accomplish it will help you get a better, more detailed answer :)
For a school project I am attempting to write what is described as an "interactive diagnosis environment" using prolog. The user will enter a symptom, and a list of diseases that match the symptom will be printed to the screen. The user will then list another symptom, and diseases will be removed from the previous list if they do not match the second symptom, forming a new list. The new list is then printed.
example user input:
SYMPTOM_IN(fever, 150).
SYMPTOM_IN(vomiting, 1).
A list of possible diseases is printed after each input.
This process is repeated until a diagnosis is made or until it is somehow determined that it can't, at which point tests will be suggested and the user can input data regarding the tests in a similar manner, ultimately arriving at a diagnosis.
So far, all I have is a list of facts that will compile and that I can then interact with, but I really don't understand how I am supposed to carry over the list of diseases from one input to the next. I also don't understand how to move from taking symptom input to suggesting tests, although maybe that will be evident once I understand how to do the symptom input portion.
I would really appreciate any help.
Thanks.
EDIT:
Could I take the two values from the SYMPTOM_IN call, use them to do something like symptom(X, fever, 150)., and assert the output from that to store it (like in the answer to this question)? Then maybe I can do the same thing for the next call and take the union of the two lists?
You want to create an expert system. There is a lot of info about it on the net. For example:
https://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_17.html
http://www.amzi.com/ExpertSystemsInProlog/02usingprolog.php
There is also a lot of good info on Stack Overflow.
In short: you need to know how to use assert and retract in proper way.
Quick rundown, basically, the idea of the prolog program (GNU Prolog) is to search a database containing people with available time slots to a set of times (beginning time, end time) and return the first person who can meet in that time. The input has the syntax
meeting(Person,slot(time(10,0),time(12,30)))
I have a predicate which matches the above as such:
meeting(Person, slot(time(A,B),time(C,D))) :- %insert code
and the database entries look as such:
free(george,slot(time(9,30),time(11,0)))
Where I am stuck is that I'm not sure how I can compare the times in the database with the times entered when calling my meeting predicate. Not looking for a free answer, just wanting a push in the right direction and a good example :) Thanks everyone!
Doing what mbratch said, I saw better how prolog runs through the database and I was able to easily write come comparing logic which would satisfy the requirements.
The idea is, calling free(...) as above, Person receives the first individual in the list and all the passed variables receive the data. Then I could use my logic on the data and if all the logic passes, the method runs through and the proper response is returned.
Thanks for your help!