Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- 5.py +78 -0
- README.md +3 -9
- app.log +0 -0
- docs/your_data.csv +0 -0
- employee_works.txt +23 -0
- requirements.txt +5 -0
5.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
from datetime import datetime
|
3 |
+
import re
|
4 |
+
import gradio as gr
|
5 |
+
import requests
|
6 |
+
from io import BytesIO, StringIO
|
7 |
+
|
8 |
+
# URL of the CSV file
|
9 |
+
CSV_URL = "https://huggingface.co/spaces/mhammad/Khanfar/raw/main/docs/your_data.csv"
|
10 |
+
|
11 |
+
def read_csv_from_url(url, start_date, end_date):
|
12 |
+
mechanics_work = {}
|
13 |
+
cash_amount = 0
|
14 |
+
response = requests.get(url)
|
15 |
+
lines = response.text.split("\n")
|
16 |
+
reader = csv.DictReader(lines)
|
17 |
+
for row in reader:
|
18 |
+
if row['ุชูุฑูุฑ ููุงุฆู'] and 'ุดููู' in row['ุชูุฑูุฑ ููุงุฆู']:
|
19 |
+
try:
|
20 |
+
entry_date = datetime.strptime(row['ุชุงุฑูุฎ ุงูุฏุฎูู'], '%d.%m.%Y')
|
21 |
+
except ValueError:
|
22 |
+
print(f"Error parsing date for row: {row}")
|
23 |
+
continue
|
24 |
+
|
25 |
+
if start_date <= entry_date <= end_date:
|
26 |
+
mechanic = row['ุงุณู
ุงูู
ููุงูููู'].strip() # Remove trailing spaces
|
27 |
+
if mechanic in mechanics_work:
|
28 |
+
mechanics_work[mechanic]['job_count'] += 1
|
29 |
+
amount_str = row['ุชูุฑูุฑ ููุงุฆู']
|
30 |
+
amount = re.findall(r'(\d+(\.\d+)?) ุดููู', amount_str)
|
31 |
+
if amount:
|
32 |
+
mechanics_work[mechanic]['total_money'] += float(amount[0][0])
|
33 |
+
else:
|
34 |
+
mechanics_work[mechanic] = {'job_count': 1, 'total_money': 0}
|
35 |
+
amount_str = row['ุชูุฑูุฑ ููุงุฆู']
|
36 |
+
amount = re.findall(r'(\d+(\.\d+)?) ุดููู', amount_str)
|
37 |
+
if amount:
|
38 |
+
mechanics_work[mechanic]['total_money'] = float(amount[0][0])
|
39 |
+
|
40 |
+
# Check if ุฑูู
ุงูู
ุฑูุจุฉ and ููุน ุงูู
ุฑูุจู are both "ูุงุด"
|
41 |
+
if row['ุฑูู
ุงูู
ุฑูุจุฉ'].strip() == 'ูุงุด' and row['ููุน ุงูู
ุฑูุจู'].strip() == 'ูุงุด':
|
42 |
+
cash_amount += float(re.findall(r'(\d+(\.\d+)?) ุดููู', row['ุชูุฑูุฑ ููุงุฆู'])[0][0])
|
43 |
+
return mechanics_work, cash_amount
|
44 |
+
|
45 |
+
def start_processing(start_date_str, end_date_str):
|
46 |
+
start_date = datetime.strptime(start_date_str, '%d.%m.%Y')
|
47 |
+
end_date = datetime.strptime(end_date_str, '%d.%m.%Y')
|
48 |
+
|
49 |
+
work_by_date_range, total_amount = read_csv_from_url(CSV_URL, start_date, end_date)
|
50 |
+
output_text = create_output_text(work_by_date_range, total_amount, start_date, end_date)
|
51 |
+
|
52 |
+
return output_text
|
53 |
+
|
54 |
+
def create_output_text(data, total_amount, start_date, end_date):
|
55 |
+
output = f' ARAFAR JOB Calc. from date ({start_date.strftime("%d.%m.%Y")}) to date ({end_date.strftime("%d.%m.%Y")})\n'
|
56 |
+
output += '#' * 70 + '\n'
|
57 |
+
output += '-' * 50 + '\n'
|
58 |
+
output += f'Total Amount: {total_amount} ุดููู (Total Jobs: {sum(info["job_count"] for info in data.values())})\n'
|
59 |
+
output += '-' * 50 + '\n'
|
60 |
+
for mechanic, info in data.items():
|
61 |
+
output += f'{mechanic}: {info["total_money"]} ุดููู (Total Jobs: {info["job_count"]})\n'
|
62 |
+
output += '-' * 50 + '\n'
|
63 |
+
return output
|
64 |
+
|
65 |
+
output_text = gr.Textbox(label="Output")
|
66 |
+
|
67 |
+
iface = gr.Interface(
|
68 |
+
fn=start_processing,
|
69 |
+
inputs=[
|
70 |
+
gr.Textbox(label="ู
ู ุชุงุฑูุฎ (dd.mm.yyyy)"),
|
71 |
+
gr.Textbox(label="ุงูู ุชุงุฑูุฎ (dd.mm.yyyy)")
|
72 |
+
],
|
73 |
+
outputs=output_text,
|
74 |
+
title="ุญุงุณุจุฉ ุงูุนู
ู ูุงูู
ูุธููู",
|
75 |
+
description="ุงุญุณุจ ุงูุนู
ู ูุงูู
ูุธููู ูู ูุชุฑุฉ ู
ุนููุฉ"
|
76 |
+
)
|
77 |
+
|
78 |
+
iface.launch()
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title: Emp
|
3 |
-
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Emp-Salary
|
3 |
+
app_file: 5.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
+
sdk_version: 3.50.2
|
|
|
|
|
6 |
---
|
|
|
|
app.log
ADDED
The diff for this file is too large to render.
See raw diff
|
|
docs/your_data.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
employee_works.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ARAFAR JOB Calc. from date (13.04.2024) to date (17.04.2024)
|
2 |
+
######################################################################
|
3 |
+
--------------------------------------------------
|
4 |
+
Total Amount: 2250.0 ุดููู (Total Jobs: 49)
|
5 |
+
--------------------------------------------------
|
6 |
+
: 2650.0 ุดููู (Total Jobs: 7)
|
7 |
+
--------------------------------------------------
|
8 |
+
ุงุจู ุงูุดูุฎ: 1750.0 ุดููู (Total Jobs: 9)
|
9 |
+
--------------------------------------------------
|
10 |
+
ุงุจู ุงูู
ุดุงูุฎ: 1900.0 ุดููู (Total Jobs: 6)
|
11 |
+
--------------------------------------------------
|
12 |
+
ุงูุนุฒุจ: 2300.0 ุดููู (Total Jobs: 3)
|
13 |
+
--------------------------------------------------
|
14 |
+
ุดุฌุงุน: 2450.0 ุดููู (Total Jobs: 5)
|
15 |
+
--------------------------------------------------
|
16 |
+
ุฒูุฏ: 4250.0 ุดููู (Total Jobs: 9)
|
17 |
+
--------------------------------------------------
|
18 |
+
ุงุณุงู
ู: 3800.0 ุดููู (Total Jobs: 7)
|
19 |
+
--------------------------------------------------
|
20 |
+
ุงุจู ุงููุจูู: 100.0 ุดููู (Total Jobs: 1)
|
21 |
+
--------------------------------------------------
|
22 |
+
ุงุฏูู
: 900.0 ุดููู (Total Jobs: 2)
|
23 |
+
--------------------------------------------------
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==2.3.6
|
2 |
+
requests==2.26.0
|
3 |
+
gTTS==2.4.0
|
4 |
+
pygame==2.5.2
|
5 |
+
openai==0.28.1
|