Function for checking a CSV file against a database