OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

pandas skip a column

  • Thread starter Thread starter Jack Daniels
  • Start date Start date
J

Jack Daniels

Guest
I'm traversing a csv using pandas. The csv is uneven i.e. some extra columns (in some rows) with no headers. I'm getting this error

Code:
pandas.errors.ParserError: Error tokenizing data. C error: Expected 11 fields in line 8, saw 12

I read some solutions but some of them are skipping the whole line and other suggesting a manual tweaking. I can not afford both. I need a method that can remove the extra column keeping the rest of row.

Here's example of data

Code:
Country    Phone         Fax    
Germany 030-0074321    030-0076545
Mexico  (5) 555-4729   (5) 555-3745
Mexico  (5) 555-3932    NULL
67000   France         88.60.15.31      88.60.15.32
28023   Spain          (91) 555 22 82   (91) 555 91 99

Any help will be appreciated.
<p>I'm traversing a csv using pandas. The csv is uneven i.e. some extra columns (in some rows) with no headers. I'm getting this error</p>

<pre><code>pandas.errors.ParserError: Error tokenizing data. C error: Expected 11 fields in line 8, saw 12
</code></pre>

<p>I read some solutions but some of them are skipping the whole line and other suggesting a manual tweaking. I can not afford both.
I need a method that can remove the extra column keeping the rest of row.</p>

<p>Here's example of data</p>

<pre><code>Country Phone Fax
Germany 030-0074321 030-0076545
Mexico (5) 555-4729 (5) 555-3745
Mexico (5) 555-3932 NULL
67000 France 88.60.15.31 88.60.15.32
28023 Spain (91) 555 22 82 (91) 555 91 99
</code></pre>

<p>Any help will be appreciated.</p>
 
Top