-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # server/server/api/reports.py
- Loading branch information
Showing
26 changed files
with
434 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from server.config import ParseConfig | ||
from server.parsing.loading_classroom_file import ParseClassFile | ||
from server.parsing.parse_class_file import ParseClassFile | ||
from collections import namedtuple | ||
|
||
|
||
parser = ParseClassFile.from_object(ParseConfig) | ||
|
||
AttendanceMetaData = namedtuple('meta_data', ['filter_modes', 'time_delta', 'start_sentence', 'not_included_zoom_users']) | ||
AttendanceMetaData = namedtuple('meta_data', ['filter_modes', 'time_delta', 'start_sentence', 'zoom_names_to_ignore']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import re | ||
|
||
DELETE_ROWS_CONTAIN = ["הופק בתאריך"] #TODO: need to remove to config | ||
|
||
class ParseClassFile: | ||
|
||
def __init__(self, file_cols_dict, mashov_cols, gender_dict): | ||
self._file_cols_dict = file_cols_dict | ||
self._mashov_cols = mashov_cols | ||
self._gender_dict = gender_dict | ||
|
||
@classmethod | ||
def from_object(cls, config): | ||
return cls( | ||
config.FILE_COLS_DICT, | ||
config.MASHOV_COLS, | ||
config.GENDER_DICT | ||
) | ||
|
||
def parse_df(self, df_students): | ||
|
||
if ParseClassFile.check_if_mashov_file(df_students): | ||
df_students = self.mashov_file(df_students) | ||
else: | ||
df_students = self.classic_file(df_students) | ||
|
||
for col in self._file_cols_dict.keys(): | ||
try: | ||
df_students[col] = df_students[col] | ||
except KeyError: | ||
df_students[col] = pd.Series([np.nan] * df_students.shape[0]) | ||
|
||
final_df = df_students[list(self._file_cols_dict.keys())] | ||
|
||
return final_df.reset_index().drop(columns="index") | ||
|
||
|
||
@staticmethod | ||
def check_if_mashov_file(df_students): | ||
df_students.dropna(axis=0, how="all", inplace=True) | ||
df_students.dropna(axis=1, how="all", inplace=True) | ||
|
||
for col in df_students.columns: | ||
if df_students[col].astype(str).str.match(r"(\d+.)([\u0590-\u05fe ]+)([(\u0590-\u05fe)]+)").any(): | ||
df_students.rename(columns={col: "name"}, inplace=True) | ||
return True | ||
return False | ||
|
||
def mashov_file(self, df_students): | ||
df_t = df_students.T | ||
cols_to_drop = [] | ||
for col in df_t.columns: | ||
if df_t[col].str.contains('|'.join(DELETE_ROWS_CONTAIN)).any(): | ||
cols_to_drop.append(col) | ||
df_students = df_t.drop(columns=cols_to_drop).T | ||
|
||
df_students.rename(columns={"ת.ז.": 'id_number', "כיתה": "org_class"}, inplace=True) | ||
try: | ||
df_students = df_students.loc[:, self._mashov_cols] | ||
except KeyError: | ||
raise ValueError("File content is invalid to the program configurations") | ||
|
||
mashov_name_pattern = re.compile(r"([\u0590-\u05fe ]+)([(\u0590-\u05fe)]+)") | ||
df_name_gender = df_students['name'].str.extract(mashov_name_pattern, expand=False) | ||
df_students['gender'] = df_name_gender[1].str.extract("\(([\u0590-\u05fe ])\)") | ||
df_students['gender'] = df_students['gender'].apply(self.gender_assign, gender_dict=self._gender_dict) | ||
df_students['name'] = df_name_gender[0] | ||
return df_students | ||
|
||
|
||
def classic_file(self, df_students): | ||
relevant_cols = [col for col in df_students.columns if not col.startswith("Unnamed")] | ||
current_excel_dict = {} | ||
for col in relevant_cols: | ||
for key, col_options in self._file_cols_dict.items(): | ||
if col in col_options: | ||
current_excel_dict[key] = df_students[col] | ||
return pd.DataFrame(current_excel_dict) | ||
|
||
|
||
@staticmethod | ||
def gender_assign(string, gender_dict): | ||
for key, vals in gender_dict.items(): | ||
if string in vals: | ||
return key | ||
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
1 change: 1 addition & 0 deletions
1
server/test/files_to_test/chat_files/chat_file_not_structured.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
I love to go to school |
4 changes: 4 additions & 0 deletions
4
server/test/files_to_test/chat_files/chat_file_not_structured_partially.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
10:56:16 From | ||
10:56:18 From | ||
10:56:19 From | ||
10:56:20 From |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# teacher = "Roei teacher", "start sentence": "בדיקת נוכחות, zoom_names_to_ignore = ["Roei", "Elad Visitor"] | ||
|
||
# session 1 - should find ["מיכל קליימן", "ענבר עדי", "זאב הרצל"]. In case of >=3 minutes check & check with phone (as well) - will find "מיתר כהן" | ||
|
||
10:46:16 From Roei teacher : בדיקת נוכחות: | ||
10:46:18 From Idan Aviv : here | ||
10:46:19 From Michal : מיכל קליימן | ||
10:46:20 From Inbar Adi : ענבר עדי | ||
10:46:22 From Zeave H : 305696031 | ||
10:48:22 From Meitar : 537642324 | ||
|
||
|
||
# session 2 - should find ["מיכל קליימן", "ענבר עדי", "אביתר כהן", "עידן אביב"]. here "Zeave H" (wrote another name and then himself - will ignore it). minutes >=2 for "מיתר כהן" | ||
10:57:22 From Roei teacher : בדיקת נוכחות: | ||
10:57:42 From Zeave H : אביתר כהן | ||
10:57:43 From Idan Aviv : עידן אביב | ||
10:57:52 From Zeave H : 305696031 | ||
10:57:53 From Inbar Adi : ענבר עדי | ||
10:57:54 From Michal : מיכל קליימן | ||
10:57:55 From Dana : here | ||
10:58:46 From Ron : רון זהבי | ||
10:58:54 From Meitar : 537642324 | ||
|
||
# session 3 - should find ["מיכל קליימן", "עידן אביב"] - checking not auth user writing the "start sentence" | ||
|
||
11:57:16 From Roei teacher : בדיקת נוכחות | ||
11:57:43 From Idan Aviv : עידן אביב | ||
11:57:43 From Idan Aviv : שלום | ||
11:57:45 From Idan Aviv : בדיקת נוכחות | ||
11:57:46 From Elad Visitor : my not relevant message I'm visitor | ||
11:57:54 From Michal : מיכל קליימן | ||
|
10 changes: 10 additions & 0 deletions
10
server/test/files_to_test/students_list_excel/example_csv.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
id,phone,id_number,name,org_class,gender,class_id | ||
11,528702484,305049421,???? ????,,, | ||
12,524291930,123424343,????? ???,,, | ||
13,526148959,432424455,???? ??????,,, | ||
14,523454564,423423649,???? ???,,, | ||
15,530342423,305696031,??? ????,,, | ||
16,530342413,305696041,???? ??????,,, | ||
17,537642324,534234210,???? ???,,, | ||
,,,,,, | ||
18,537642324,534234453,???? ???,,, |
8 changes: 8 additions & 0 deletions
8
server/test/files_to_test/students_list_excel/example_csv_2.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
id,phone,id_number,name,org_class,gender,class_id, | ||
11,528702484,305049421,???? ????,,,, | ||
12,524291930,123424343,????? ???,,,, | ||
13,526148959,432424455,???? ??????,,,, | ||
14,523454564,423423649,???? ???,,,, | ||
15,530342423,305696031,??? ????,,,, | ||
16,530342413,305696041,???? ??????,,,, | ||
17,537642324,534234210,???? ???,,,, |
1 change: 1 addition & 0 deletions
1
server/test/files_to_test/students_list_excel/example_csv_3.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
server/test/files_to_test/students_list_excel/example_csv_4.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
id,phone,id_number,name,org_class,gender,class_id, | ||
11,528702484,305049421,???? ????,,,, | ||
12,524291930,123424343,????? ???,,,, | ||
13,526148959,432424455,???? ??????,,,, | ||
14,523454564,423423649,???? ???,,,, | ||
15,530342423,305696031,??? ????,,,, | ||
16,530342413,305696041,???? ??????,,,, | ||
17,537642324,534234210,???? ???,,,, |
Binary file not shown.
Binary file added
BIN
+10.9 KB
server/test/files_to_test/students_list_excel/example_excel_start_in_random_row.xlsx
Binary file not shown.
Binary file added
BIN
+15.9 KB
server/test/files_to_test/students_list_excel/example_excel_too_much_records.xlsx
Binary file not shown.
Binary file added
BIN
+40.5 KB
server/test/files_to_test/students_list_excel/example_mashov_file_edited_and_saved_97.xls
Binary file not shown.
Binary file added
BIN
+40.5 KB
..._to_test/students_list_excel/example_mashov_file_edited_and_saved_97_with_filled_data.xls
Binary file not shown.
Binary file added
BIN
+39 KB
server/test/files_to_test/students_list_excel/example_mashov_file_empty.xls
Binary file not shown.
Binary file added
BIN
+10.8 KB
server/test/files_to_test/students_list_excel/דוגמה לרשימת תלמידים.xlsx
Binary file not shown.
Oops, something went wrong.