To keep running when the data is empty in Python

Machine learning is a method that involves methods with datasets. Sometimes when the dataset to be processed is empty an error will appear as below.

Several ways can be taken, but the easiest way is to check the size of the csv file. If the file size is zero Kb then it is confirmed that there is no content. Then just use the ‘if not’ instruction as sample below.

Here, the ‘os’ library is required. Don’t forget to indent the ‘if’, including the ‘else:’ side.