# Parsing A CSV With Quotes In The Data

If a CSV contains unescaped quote characters--like you might find in a CSV full of measurement data--then Ruby's [CSV](https://ruby-doc.org/stdlib-2.6.1/libdoc/csv/rdoc/CSV.html) library will be unable to parse it.

Here is what happens with a line of CSV about some lumber:

```ruby
> require 'csv'
> CSV.parse_line('oak,2",4"')
CSV::MalformedCSVError (Illegal quoting in line 1.)
```

However, we can enable some more lenient, liberal parsing of the data with the `liberal_parsing` argument.

```ruby
> require 'csv'
> CSV.parse_line('oak,2",4"', liberal_parsing: true)
=> ["oak", "2\"", "4\""]
```

[source](https://blog.bigbinary.com/2016/11/22/ruby-2-4-introduces-liberal_parsing-option-for-parsing-bad-csv-data.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/ruby/parsing-a-csv-with-quotes-in-the-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
