Compare commits

..

10 Commits

Author SHA1 Message Date
Crai-cry
e9754677c9 Merge branch 'only_task' 2026-04-04 11:46:53 +03:00
Crai-cry
73ecd7d386 finished work 2026-03-29 21:40:25 +03:00
Crai-cry
2396d73b2f change encoding 2026-03-28 16:20:56 +03:00
Crai-cry
9c91448815 10/10 2026-03-27 19:26:54 +03:00
Crai-cry
82b4b3094a 10/10 func 2026-03-27 10:15:43 +03:00
Crai-cry
aedebb3eba delet all what dont need 2026-03-24 22:00:55 +03:00
Crai-cry
7555dc3319 make 9/10 func 2026-03-24 19:14:19 +03:00
Crai-cry
72d5a28f16 add interface and start working on logic 2026-03-24 16:13:55 +03:00
Crai-cry
ad95e00c84 make venv 2026-03-24 15:44:33 +03:00
Crai-cry
b3f70c0c9d add all 10 prototype func 2026-03-23 21:30:41 +03:00
6 changed files with 158 additions and 7 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.venv/
__pycache__/
*.pyc
output.txt
*.docx

1
answer/1try.txt Normal file
View File

@ -0,0 +1 @@
ID 2: Data Engineer в Тинькофф, Москва — от 180000 до 250000ID 6: Senior Python Developer в Wildberries, Москва — от 200000 до 300000

72
data/test.json Normal file
View File

@ -0,0 +1,72 @@
[
{
"id": 1,
"title": "Python разработчик",
"company": "Яндекс",
"city": "Москва",
"salary_from": 150000,
"salary_to": 200000,
"skills": ["Python", "SQL", "Django", "PostgreSQL"],
"published_at": "2024-01-15"
},
{
"id": 2,
"title": "Data Engineer",
"company": "Тинькофф",
"city": "Москва",
"salary_from": 180000,
"salary_to": 250000,
"skills": ["Python", "SQL", "Spark", "Airflow"],
"published_at": "2024-01-20"
},
{
"id": 3,
"title": "Backend Developer",
"company": "Ozon",
"city": "Санкт-Петербург",
"salary_from": 130000,
"salary_to": 170000,
"skills": ["Python", "FastAPI", "MongoDB"],
"published_at": "2024-01-18"
},
{
"id": 4,
"title": "Data Analyst",
"company": "Яндекс",
"city": "Москва",
"salary_from": 140000,
"salary_to": 180000,
"skills": ["Python", "SQL", "Tableau"],
"published_at": "2024-01-22"
},
{
"id": 5,
"title": "Junior Python Developer",
"company": "Сбер",
"city": "Москва",
"salary_from": 100000,
"salary_to": 130000,
"skills": ["Python", "SQL", "Git"],
"published_at": "2024-01-25"
},
{
"id": 6,
"title": "Senior Python Developer",
"company": "Wildberries",
"city": "Москва",
"salary_from": 200000,
"salary_to": 300000,
"skills": ["Python", "SQL", "Kafka", "Kubernetes"],
"published_at": "2024-01-28"
},
{
"id": 7,
"title": "Full Stack Developer",
"company": "Avito",
"city": "Москва",
"salary_from": 170000,
"salary_to": 220000,
"skills": ["Python", "JavaScript", "React", "SQL"],
"published_at": "2024-01-30"
}
]

0
requirements.txt Normal file
View File

0
results/answer.csv Normal file
View File

View File

@ -1,17 +1,89 @@
import json import json
from typing import List, Dict from collections import Counter
def load_vacancies(filepath: str) -> List[Dict]: def load_vacancies(filepath: str) -> list[dict]:
try: try:
with open(filepath,"r") as file: with open(filepath,"r") as file:
return json.load(file) return json.load(file)
except: except:
print() print()
return [] return []
def filter_by_city(vacancies: List[Dict], city: str) -> List[Dict]: def filter_by_city(vacancies: list[dict], city: str) -> list[dict]:
return [i for i in vacancies if i.get('city').lower() == city.lower()] return [i for i in vacancies if i.get('city','').lower() == city.lower()]
def filter_by_skills(vacancies: list[dict], required_skills: list[str]) -> list[dict]:
return [i for i in vacancies if all(skill.lower() in set(k.lower() for k in i.get('skills')) for skill in required_skills ) ]
def filter_by_salary(vacancies: list[dict], min_salary: int) -> list[dict]:
return [v for v in vacancies if v.get('salary_to') and v.get('salary_from') and v.get('salary_to')>= min_salary and v.get('salary_from')> min_salary]
def extract_unique_companies(vacancies: list[dict]) -> list[str]:
return list({v.get('company') for v in vacancies if v.get('company')})
def extract_top_skills(vacancies: list[dict], top_n: int) -> list[tuple[str, int]]:
all_skills = []
for v in vacancies:
all_skills.extend(v.get('skills', []))
skill_counts = Counter(all_skills)
return skill_counts.most_common(top_n)
def calculate_average_salary(vacancies: list[dict]) -> float:
if not vacancies:
return 0.0
else:
salaries = []
for v in vacancies:
salary_from = v.get('salary_from')
salary_to = v.get('salary_to')
if salary_from is not None and salary_to is not None:
salaries.append((salary_from + salary_to) / 2)
elif salary_from is not None:
salaries.append(salary_from)
elif salary_to is not None:
salaries.append(salary_to)
if not salaries:
return 0.0
return sum(salaries) / len(salaries)
def group_by_company(vacancies: list[dict]) -> dict[str, int]:
all_company = []
for v in vacancies:
all_company.append(v.get('company'))
company_count = Counter(all_company)
return company_count
def format_vacancy_short(vacancy: dict) -> str:
salary_from = vacancy.get('salary_from')
salary_to = vacancy.get('salary_to')
if salary_from is not None and salary_to is not None:
salary_str = f"от {salary_from} до {salary_to}"
elif salary_from is not None:
salary_str = f"от {salary_from}"
elif salary_to is not None:
salary_str = f"до {salary_to}"
else:
salary_str = "зарплата не указана"
return (f"ID {vacancy.get('id')}: {vacancy.get('title')} в {vacancy.get('company')}, "
f"{vacancy.get('city')}{salary_str}\n")
def save_filtered_results(vacancies: list[dict], filename: str) -> bool:
try:
with open(filename,"w") as file:
file.writelines(format_vacancy_short(x) for x in vacancies)
return 0
except:
return 1
def main(): def main():
print("Hello World") main_list=load_vacancies(input("Write path for json:"))
filered_vacancies = filter_by_city(main_list,input("Write city"))
skils_list=[]
for i in range(int(input("Write number of skills: "))):
skils_list.append(input(f"Write №{i + 1} skill: "))
filered_vacancies=filter_by_skills(filered_vacancies,skils_list)
filered_vacancies = filter_by_salary(filered_vacancies,int(input("Write salary: ")))
print("Уникальные компании: ", ", ".join(extract_unique_companies(filered_vacancies)))
top_skills = extract_top_skills(filered_vacancies, 5)
print(f"Топ-5 навыков:")
for skill, count in top_skills:
print(f" {skill}: {count} вакансий")
print(f"\nСредняя зарплата: {calculate_average_salary(filered_vacancies):,.0f} руб.")
for company, count in group_by_company(filered_vacancies).items():
print(f" {company}: {count} вакансий")
if(save_filtered_results(filered_vacancies,input("Write where to save"))):
print("Check your path")
else:
print("Everything is fine, the file is saved")
if __name__ =="__main__": if __name__ =="__main__":
#òóïî âûâîä #вход проги
main() main()