mhammad commited on
Commit
b1d7470
ยท
verified ยท
1 Parent(s): cc2a637

Upload 6 files

Browse files
Files changed (6) hide show
  1. 5.py +78 -0
  2. README.md +3 -9
  3. app.log +0 -0
  4. docs/your_data.csv +0 -0
  5. employee_works.txt +23 -0
  6. 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 Salary
3
- emoji: ๐Ÿข
4
- colorFrom: yellow
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.27.0
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