How do I open a tab delimited text file in pandas so that I can then use it for exploratory data analysis?
<p>I have a tab delimited file with data about some movies. Some movie titles are enclosed in a double quote. How can I read the file into a pandas dataframe and how can I remove the double quote from the movie titles?  </p>

<p>I know how to do it in R and I know how to remove the double quotes. However, is there an equivalent function in pandas to do that? But most importantly how do I load it into a pandas dataframe?</p>

<p>First you can read tab delimited files using either <code>read_table</code> or <code>read_csv</code>. The former uses tab delimiter by default, for the latter you need to specify it:</p>

<pre><code>import pandas as pd
df = pd.read_csv('yourfile.txt', sep='\t')
</code></pre>

<p>Or:</p>

<pre><code>import pandas as pd
df = pd.read_table('yourfile.txt')
</code></pre>

<p>If you are receiving encoding errors it is because <code>read_table</code> doesn't understand the text encoding of the file. You can solve this by specifying the encoding directly, for example for UTF8:</p>

<pre><code>import pandas as pd
df = pd.read_table('yourfile.txt', encoding='utf8') 
</code></pre>

<p>If you file is using a <a href="https://docs.python.org/2.4/lib/standard-encodings.html" rel="nofollow">different encoding</a>, you will need to specify that instead.</p>

python pandas