Skip to content

Commit 513550e

Browse files
Task 1 is done
1 parent 0c2dd0e commit 513550e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CW2 (2).py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ def load_data(file_path, delimiter=','):
2424
warnings.warn(f"Task 1: Warning - CSV file '{file_path}' does not exist.")
2525
return None, None, None
2626
# Insert your code here for task 1
27+
try:
28+
data = pd.read_csv(file_path, delimiter=delimiter) # reads the data from the file
29+
num_rows = data.shape[0] # gets the number of rows in the data
30+
header_list = list(data.columns) # gets the header list of the data
31+
except Exception as e:
32+
warnings.warn(f"Task 1: Warning - Error in reading the CSV file '{file_path}'. {e}")
33+
return None, None, None
2734
return num_rows, data, header_list
2835

2936
# Task 2[10 marks]: Give back the data by removing the rows with -99 values

0 commit comments

Comments
 (0)