Closed sabhatia closed 9 months ago
Tested and works for the last row and first row.
C:\Users\sabha\OneDrive\Coding Projects\CRUD\CRUD> python .\db_interface.py Employee.csv [STATUS]: Initialized DB with 4653 records. File Operations [0] Display all records [1] Display records [2] Delete records [3] Update records [4] Exit Your Selection: 2 [STATUS]: : Delete Records Enter record to delete [1 - 4653]: 4653 ['Education', 'JoiningYear', 'City', 'PaymentTier', 'Age', 'Gender', 'EverBenched', 'ExperienceInCurrentDomain', 'LeaveOrNot'] Record 4651: ['Masters', '2018', 'New Delhi', '3', '27', 'Male', 'No', '5', '1'] Record 4652: ['Bachelors', '2012', 'Bangalore', '3', '30', 'Male', 'Yes', '2', '0'] [STATUS]: Record 4653 deleted ['Education', 'JoiningYear', 'City', 'PaymentTier', 'Age', 'Gender', 'EverBenched', 'ExperienceInCurrentDomain', 'LeaveOrNot'] Record 4651: ['Masters', '2018', 'New Delhi', '3', '27', 'Male', 'No', '5', '1'] Record 4652: ['Bachelors', '2012', 'Bangalore', '3', '30', 'Male', 'Yes', '2', '0'] File Operations [0] Display all records [1] Display records [2] Delete records [3] Update records [4] Exit Your Selection:
Tested and ensure as working
File Operations [0] Display all records [1] Display records [2] Delete records [3] Update records [4] Exit Your Selection: 2 [STATUS]: : Delete Records Enter record to delete [1 - 4653]: 4653 ['Education', 'JoiningYear', 'City', 'PaymentTier', 'Age', 'Gender', 'EverBenched', 'ExperienceInCurrentDomain', 'LeaveOrNot'] Record 4651: ['Masters', '2018', 'New Delhi', '3', '27', 'Male', 'No', '5', '1'] Record 4652: ['Bachelors', '2012', 'Bangalore', '3', '30', 'Male', 'Yes', '2', '0'] [STATUS]: Record 4653 deleted ['Education', 'JoiningYear', 'City', 'PaymentTier', 'Age', 'Gender', 'EverBenched', 'ExperienceInCurrentDomain', 'LeaveOrNot'] Record 4651: ['Masters', '2018', 'New Delhi', '3', '27', 'Male', 'No', '5', '1'] Record 4652: ['Bachelors', '2012', 'Bangalore', '3', '30', 'Male', 'Yes', '2', '0'] File Operations [0] Display all records [1] Display records [2] Delete records [3] Update records [4] Exit Your Selection: 1 [STATUS]: : Display Records Total Records: 4652 Enter starting range: [1 - 4652]: 4650 Enter last record: [4651 - 4653]: 4653 ['Education', 'JoiningYear', 'City', 'PaymentTier', 'Age', 'Gender', 'EverBenched', 'ExperienceInCurrentDomain', 'LeaveOrNot'] Record 4650: ['Masters', '2013', 'Pune', '2', '37', 'Male', 'No', '2', '1'] Record 4651: ['Masters', '2018', 'New Delhi', '3', '27', 'Male', 'No', '5', '1'] Record 4652: ['Bachelors', '2012', 'Bangalore', '3', '30', 'Male', 'Yes', '2', '0'] File Operations [0] Display all records [1] Display records [2] Delete records [3] Update records [4] Exit Your Selection:
In a DB with 4653 records, deleting record #4653 given an error. The console output is pasted below.
Issue probably is that list-index is 0 based, but record indexing for the DB is 1-based. So last record has to be treated properly.
Console Output
[STATUS]: Initialized DB with 4653 records. File Operations [0] Display all records [1] Display records [2] Delete records [3] Update records [4] Exit Your Selection: 2 [STATUS]: : Delete Records Enter record to delete [1 - 4653]: 4653 ['Education', 'JoiningYear', 'City', 'PaymentTier', 'Age', 'Gender', 'EverBenched', 'ExperienceInCurrentDomain', 'LeaveOrNot'] Record 4651: ['Masters', '2018', 'New Delhi', '3', '27', 'Male', 'No', '5', '1'] Record 4652: ['Bachelors', '2012', 'Bangalore', '3', '30', 'Male', 'Yes', '2', '0'] Record 4653: ['Bachelors', '2015', 'Bangalore', '3', '33', 'Male', 'Yes', '4', '0'] [STATUS]: Record 4653 deleted Traceback (most recent call last): File "C:\Users\sabha\OneDrive\Coding Projects\CRUD\CRUD\db_interface.py", line 117, in
while (display_and_parse_console(csv_table) != END):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sabha\OneDrive\Coding Projects\CRUD\CRUD\db_interface.py", line 91, in display_and_parse_console
ret_val = user_cmds_dictuser_cmd
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sabha\OneDrive\Coding Projects\CRUD\CRUD\db_interface.py", line 64, in delete_records
mem_db.display_recs(first_row, last_row)
File "C:\Users\sabha\OneDrive\Coding Projects\CRUD\CRUD\memory_db.py", line 56, in display_recs
assert(last_row > first_row and last_row <= total_recs)
AssertionError
PS C:\Users\sabha\OneDrive\Coding Projects\CRUD\CRUD>