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.


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.