'How to delete rows that exceed a certain amount of columns

Working on putting csv files into a dataframe and loading it into a database, but there are a few files that have rows with data in extra columns. I want to be able to drop the entire row that exceeds 'X' amount of columns

Example, want to remove rows that have more than 4 columns

id, header1, header2, header3
1, desc1, desc2, desc3
2, desc1, desc2, desc3
3, desc1, desc2, desc3, desc4
4, desc1, desc2, desc3

I would like to skip row with id = 3, output:

id, header1, header2, header3
1, desc1, desc2, desc3
2, desc1, desc2, desc3
4, desc1, desc2, desc3


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source