Data Import
Using the `ignore_errors` Option
There are cases where CSV files may have multiple structural errors, and users simply wish to skip these and read the correct data. Reading erroneous CSV files is possible by utilizing the `ignore_errors` option. With this option set, rows containing data that would otherwise cause the CSV parser to generate an error will be ignored. In our example, we will demonstrate a CAST error, but note that any of the errors described in our Structural Error section would cause the faulty line to be skipped.  
For example, consider the following CSV file, [`faulty.csv`](https://duckdb.org/data/faulty.csv):  
```csv
Pedro,31
Oogie Boogie, three
```  
If you read the CSV file, specifying that the first column is a `VARCHAR` and the second column is an `INTEGER`, loading the file would fail, as the string `three` cannot be converted to an `INTEGER`.  
For example, the following query will throw a casting error.  
```sql
FROM read_csv('faulty.csv', columns = {'name': 'VARCHAR', 'age': 'INTEGER'});
```  
However, with `ignore_errors` set, the second row of the file is skipped, outputting only the complete first row. For example:  
```sql
FROM read_csv(
'faulty.csv',
columns = {'name': 'VARCHAR', 'age': 'INTEGER'},
ignore_errors = true
);
```  
Outputs:  
<div class="narrow_table"></div>  
| name  | age |
|-------|-----|
| Pedro | 31  |  
One should note that the CSV Parser is affected by the projection pushdown optimization. Hence, if we were to select only the name column, both rows would be considered valid, as the casting error on the age would never occur. For example:  
```sql
SELECT name
FROM read_csv('faulty.csv', columns = {'name': 'VARCHAR', 'age': 'INTEGER'});
```  
Outputs:  
<div class="narrow_table"></div>  
|     name     |
|--------------|
|     Pedro    |
| Oogie Boogie |