Pandas: How to open certain files
<p>I am currently working on the data set from this <a href="https://github.com/smarthi/UnivOfWashington-Machine-Learning/tree/master/MLFoundations/week4/people_wiki.gl" rel="nofollow">link</a>. But I am unable to read these files from Pandas? Has anyone tried to play with such files?</p>

<p>I am trying the following:</p>

<pre><code>import pandas as pd

df = pd.read_csv("m_4549381c276b46c6.0000")
</code></pre>

<p>But I get the following error</p>

<pre><code>Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.
</code></pre>

<p>Those files are parts of a saved <a href="https://turi.com/products/create/docs/generated/graphlab.SFrame.html" rel="nofollow">SFrame</a>.</p>

<p>So you can load them this way:</p>

<pre><code>import sframe

sf = sframe.SFrame('/path/to/dir/')
</code></pre>

<p>Demo: I've downloaded all files from <a href="https://github.com/smarthi/UnivOfWashington-Machine-Learning/tree/master/MLFoundations/week4/people_wiki.gl" rel="nofollow">people_wiki.gl</a> and put them under: <code>D:/download/sframe/</code></p>

<pre><code>In [7]: import sframe

In [7]: sf = sframe.SFrame('D:/download/sframe/')

In [8]: sf
Out[8]:
Columns:
        URI     str
        name    str
        text    str

Rows: 59071

Data:
+-------------------------------+---------------------+
|              URI              |         name        |
+-------------------------------+---------------------+
| &lt;http://dbpedia.org/resour... |    Digby Morrell    |
| &lt;http://dbpedia.org/resour... |    Alfred J. Lewy   |
| &lt;http://dbpedia.org/resour... |    Harpdog Brown    |
| &lt;http://dbpedia.org/resour... | Franz Rottensteiner |
| &lt;http://dbpedia.org/resour... |        G-Enka       |
| &lt;http://dbpedia.org/resour... |    Sam Henderson    |
| &lt;http://dbpedia.org/resour... |    Aaron LaCrate    |
| &lt;http://dbpedia.org/resour... |   Trevor Ferguson   |
| &lt;http://dbpedia.org/resour... |     Grant Nelson    |
| &lt;http://dbpedia.org/resour... |     Cathy Caruth    |
+-------------------------------+---------------------+
+-------------------------------+
|              text             |
+-------------------------------+
| digby morrell born 10 octo... |
| alfred j lewy aka sandy le... |
| harpdog brown is a singer ... |
| franz rottensteiner born i... |
| henry krvits born 30 decem... |
| sam henderson born october... |
| aaron lacrate is an americ... |
| trevor ferguson aka john f... |
| grant nelson born 27 april... |
| cathy caruth born 1955 is ... |
+-------------------------------+
[59071 rows x 3 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.
</code></pre>

<p>Now you can convert it to Pandas DF if you need:</p>

<pre><code>In [17]: df = sf.to_dataframe()

In [18]: pd.options.display.max_colwidth = 40

In [19]: df.head()
Out[19]:
                                       URI                 name                                     text
0  &lt;http://dbpedia.org/resource/Digby_M...        Digby Morrell  digby morrell born 10 october 1979 i...
1  &lt;http://dbpedia.org/resource/Alfred_...       Alfred J. Lewy  alfred j lewy aka sandy lewy graduat...
2  &lt;http://dbpedia.org/resource/Harpdog...        Harpdog Brown  harpdog brown is a singer and harmon...
3  &lt;http://dbpedia.org/resource/Franz_R...  Franz Rottensteiner  franz rottensteiner born in waidmann...
4     &lt;http://dbpedia.org/resource/G-Enka&gt;               G-Enka  henry krvits born 30 december 1974 i...

In [20]: df.shape
Out[20]: (59071, 3)
</code></pre>

python python-2.7 pandas dataframe