How to use square brackets as a quote character in Pandas.read_csv
<p>Let's say I have a text file that looks like this:</p>

<pre><code>Item,Date,Time,Location
1,01/01/2016,13:41,[45.2344:-78.25453]
2,01/03/2016,19:11,[43.3423:-79.23423,41.2342:-81242]
3,01/10/2016,01:27,[51.2344:-86.24432]
</code></pre>

<p>What I'd like to be able to do is read that in with <code>pandas.read_csv</code>, but the second row will throw an error. Here is the code I'm currently using:</p>

<pre><code>import pandas as pd
df = pd.read_csv("path/to/file.txt", sep=",", dtype=str)
</code></pre>

<p>I've tried to set <code>quotechar</code> to "[", but that obviously just eats up the lines until the next open bracket and adding a closing bracket results in a "string of length 2 found" error. Any insight would be greatly appreciated. Thanks!</p>

<h1>Update</h1>

<p>There were three primary solutions that were offered: 1) Give a long range of names to the data frame to allow all data to be read in and then post-process the data, 2) Find values in square brackets and put quotes around it, or 3) replace the first n number of commas with semicolons.</p>

<p>Overall, I don't think option 3 is a viable solution in general (albeit just fine for my data) because a) what if I have quoted values in one column that contain commas, and b) what if my column with square brackets is not the last column? That leaves solutions 1 and 2. I think solution 2 is more readable, but solution 1 was more efficient, running in just 1.38 seconds, compared to solution 2, which ran in 3.02 seconds. The tests were run on a text file containing 18 columns and more than 208,000 rows.</p>