Python Forum
When I read csv file i am getting b'Skipping line messages
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When I read csv file i am getting b'Skipping line messages
#1
Hi,
I read a csv file, so it reads and i can make something on it there is no problem for this. But I get lots of b'Skipping line messages. I don't want to see them.


data1 = pd.read_csv('../input/mta_1708.csv', error_bad_lines= False)
data1.head()
Error:
b'Skipping line 3356: expected 17 fields, saw 18\n' b'Skipping line 59440: expected 17 fields, saw 18\nSkipping line 61296: expected 17 fields, saw 18\n' b'Skipping line 66068: expected 17 fields, saw 18\nSkipping line 75328: expected 17 fields, saw 18\nSkipping line 81683: expected 17 fields, saw 18\nSkipping line 98179: expected 17 fields, saw 18\n' b'Skipping line 116273: expected 17 fields, saw 18\n' b'Skipping line 133094: expected 17 fields, saw 18\nSkipping line 137887: expected 17 fields, saw 18\nSkipping line 152688: expected 17 fields, saw 18\nSkipping line 160593: expected 17 fields, saw 18\n' b'Skipping line 168801: expected 17 fields, saw 18\nSkipping line 170953: expected 17 fields, saw 18\nSkipping line 179203: expected 17 fields, saw 18\n' b'Skipping line 201585: expected 17 fields, saw 18\nSkipping line 210727: expected 17 fields, saw 18\n' b'Skipping line 289132: expected 17 fields, saw 18\n' b'Skipping line 310840: expected 17 fields, saw 18\nSkipping line 311549: expected 17 fields, saw 18\nSkipping line 312390: expected 17 fields, saw 18\nSkipping line 314081: expected 17 fields, saw 18\nSkipping line 314889: expected 17 fields, saw 18\nSkipping line 319440: expected 17 fields, saw 18\n' b'Skipping line 333414: expected 17 fields, saw 18\nSkipping line 349055: expected 17 fields, saw 18\nSkipping line 354958: expected 17 fields, saw 18\nSkipping line 359424: expected 17 fields, saw 18\n' b'Skipping line 363802: expected 17 fields, saw 18\nSkipping line 371238: expected 17 fields, saw 18\nSkipping line 383152: expected 17 fields, saw 18\n' b'Skipping line 394619: expected 17 fields, saw 18\nSkipping line 396038: expected 17 fields, saw 18\nSkipping line 425194: expected 17 fields, saw 18\n' b'Skipping line 436049: expected 17 fields, saw 18\n' b'Skipping line 492943: expected 17 fields, saw 18\n' b'Skipping line 560824: expected 17 fields, saw 18\nSkipping line 562108: expected 17 fields, saw 18\nSkipping line 564761: expected 17 fields, saw 18\nSkipping line 565173: expected 17 fields, saw 18\nSkipping line 568567: expected 17 fields, saw 18\nSkipping line 576092: expected 17 fields, saw 18\n' b'Skipping line 601641: expected 17 fields, saw 18\nSkipping line 606331: expected 17 fields, saw 18\nSkipping line 618797: expected 17 fields, saw 18\nSkipping line 622388: expected 17 fields, saw 18\n' b'Skipping line 634488: expected 17 fields, saw 18\nSkipping line 649182: expected 17 fields, saw 18\nSkipping line 649962: expected 17 fields, saw 18\n' b'Skipping line 665948: expected 17 fields, saw 18\nSkipping line 671144: expected 17 fields, saw 18\nSkipping line 679474: expected 17 fields, saw 18\nSkipping line 682011: expected 17 fields, saw 18\n' b'Skipping line 691142: expected 17 fields, saw 18\nSkipping line 704452: expected 17 fields, saw 18\nSkipping line 706649: expected 17 fields, saw 18\nSkipping line 707852: expected 17 fields, saw 18\n' b'Skipping line 775405: expected 17 fields, saw 18\nSkipping line 781016: expected 17 fields, saw 18\n' b'Skipping line 797923: expected 17 fields, saw 18\nSkipping line 803890: expected 17 fields, saw 18\nSkipping line 815444: expected 17 fields, saw 18\n' b'Skipping line 831771: expected 17 fields, saw 18\nSkipping line 837856: expected 17 fields, saw 18\nSkipping line 842081: expected 17 fields, saw 18\nSkipping line 843611: expected 17 fields, saw 18\nSkipping line 844886: expected 17 fields, saw 18\nSkipping line 848631: expected 17 fields, saw 18\nSkipping line 851227: expected 17 fields, saw 18\n'
Reply
#2
Your image link does not work. Anyway, don't post images, copy/paste code, output, traceback, etc. and use respective tags when post here.

Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

Please, read What NOT to include in a post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Sorry, I have edited.
Reply
#4
you pass error_bad_line=False so it does not raise error, but issue a warning.
If you want to silence the warning, you need also pass warn_bad_lines=False

From the docs Wrote:error_bad_lines : bool, default True
Lines with too many fields (e.g. a csv line with too many commas) will by default cause an exception to be raised, and no DataFrame will be returned. If False, then these “bad lines” will dropped from the DataFrame that is returned.

warn_bad_lines : bool, default True,
If error_bad_lines is False, and warn_bad_lines is True, a warning for each “bad line” will be output.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Thank you so much.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Read csv file through PyCharm kimx0961 3 384 Aug-01-2021, 07:05 PM
Last Post: perfringo
  Why it does not print(file.read()) Rejaul84 1 376 Jul-01-2021, 10:37 PM
Last Post: bowlofred
  Read and write active Excel file euras 4 510 Jun-29-2021, 11:16 PM
Last Post: Pedroski55
  [Solved] Reading every nth line into a column from txt file Laplace12 7 743 Jun-29-2021, 09:17 AM
Last Post: Laplace12
  python seems to be skipping lines of code alansandbucket 1 418 Jun-22-2021, 01:18 AM
Last Post: Larz60+
  [Solved] Trying to read specific lines from a file Laplace12 7 716 Jun-21-2021, 11:15 AM
Last Post: Laplace12
  [Solved] Using readlines to read data file and sum columns Laplace12 4 478 Jun-16-2021, 12:46 PM
Last Post: Laplace12
  Read file, reformat and write new file bryanmartin113 1 494 Jun-08-2021, 09:27 PM
Last Post: Larz60+
Exclamation Why there's a 'blank line' on CSV file? brunolelli 4 827 Mar-25-2021, 03:43 AM
Last Post: buran
  Read/Write binary file deanhystad 3 891 Feb-01-2021, 10:29 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020