#πŸ”’ i need help

17 messages Β· Page 1 of 1 (latest)

urban merlin
#

i have a program that takes multiple excel files of students' tasks and merge them into one file. each file has columns name, score and other things... i merged them into one file and this file now has column 'score' which is the total score and another score columns for each file like 'score1', 'score2', 'score3',... based on how many files there.

i used CLI so the user enter the folder name which contains the files.

i added a column 'value' to know if a student is accepted or not based on a condition. there are many options to choose the condition from. example if the score of all tasks is higher than 10 then he is accepted.
another option: the student should have at least 10 scores in tasks 1-2 and at least 10 scores in tasks 3-4.

the user should choose the option and enter it in CLI too.
what should i do if the user wants this option: the student should have at least 20 scores in tasks 1-3 and at least 10 scores in tasks 4-6. ? i don't want the user to change the code

vagrant cloakBOT
#

@urban merlin

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

urban merlin
#

example

midnight hazel
#

and please send your code

past gust
#

!paste

vagrant cloakBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

urban merlin
#

i want that the user doesn't have to change the code.
i made a yaml file but it may be a bad idea```
my_options:

  • options: ["percentage", "tasks", "all", "range"]
    min_percentage: 10
    min_points: 100
    max_failed: 2
    number_of_tests: 4
    percentage: "Percentage"
    points: "scores in task"
    points_task: ["scores in task1","scores in task2","scores in task3","scores in task4"]```
#

and the function def process(config_file, file_name, selected): df = pd.read_excel(file_name) values = [] for index, row in df.iterrows(): result = 'accepted' for option in config_file['my_options']: mode = option['options'] min_percentage = option['min_percentage'] min_points = option['min_points'] max_failed = option['max_failed'] points_tests = option['points_tests'] max_points = row[option['max_points']] value = row[option['percentage']] points = row[option['points']] points_task1 = row[points_task[0]] points_task2 = row[points_task[1]] points_task3 = row[points_task[2]] points_task4 = row[points_task[3]] task_sum1 = points_task1 + points_task2 task_sum2 = points_task3 + points_task4 if selected == mode[0]: if value < min_percentage: result = 'not accepted' elif selected == mode[2]: if points < min_points: result = 'not accepted' elif selected == mode[3]: percentage_test1 = (points_task1 / max_points) * 100 if percentage_test1 < min_percentage: result = 'not accepted' elif selected == mode[4]: if task_sum1 < min_points: result = 'not accepted' elif selected == mode[5]: if task_sum1 < min_points or task_sum2 < min_points: result = 'not accepted' values.append(result) df['value'] = values df.to_excel(file_name, index=False)

vagrant cloakBOT
#

Hey @urban merlin!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
urban merlin
#

the user enters the selected option he wants in the terminal

#

the multiple files, each has score column. i made another function to extract these columns and rename them to be score1 and score2,... instead of score

#

now the last option check if the sum of task1 and task2 is lower than 100 and sum of task3 and 4 is lower than 100 then not accepted

#

but what if the user wants to check if the sum of task1 till 3 is lower than 100 and sum of tasks between 4 and 6 is lower than 100. then the columns score5 and score6 should be added in yaml file and in the function

#

and that means changing the code πŸ˜•

vagrant cloakBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.