0

When I run this command:

k1=pd.read_table("https://raw.githubusercontent.com/justmarkham/pandas-videos/master/data/chipotle.tsv")

I receive this error:

Command on Pandas: attached.

--------------------------------------------------------------------------- ParserError Traceback (most recent call last) in () ----> 1 pd.read_table('')

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision) 653 skip_blank_lines=skip_blank_lines) 654 --> 655 return _read(filepath_or_buffer, kwds) 656 657 parser_f.name = name

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds) 409 410 try: --> 411 data = parser.read(nrows) 412 finally: 413 parser.close()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py in read(self, nrows) 1003 raise ValueError('skipfooter not supported for iteration') 1004 -> 1005 ret = self._engine.read(nrows) 1006 1007 if self.options.get('as_recarray'):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py in read(self, nrows) 1746 def read(self, nrows=None): 1747
try: -> 1748 data = self._reader.read(nrows) 1749 except StopIteration: 1750 if self._first_chunk:

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read (pandas_libs\parsers.c:10862)()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory (pandas_libs\parsers.c:11138)()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows (pandas_libs\parsers.c:11884)()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows (pandas_libs\parsers.c:11755)()

pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error (pandas_libs\parsers.c:28765)()

ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2

Followed this stackoverflow thread, but no help

prvreddy
  • 135
  • 1
  • 2
  • 9
  • `read_table` and other `read_*` functions work on files, not webpages. – Burhan Khalid Mar 19 '18 at 05:36
  • @BurhanKhalid not sure that is true https://pandas.pydata.org/docs/reference/api/pandas.read_table.html#pandas.read_table:~:text=Any%20valid%20string%20path%20is%20acceptable.,URLs%2C%20a%20host%20is%20expected.%20A – Mark Apr 05 '21 at 21:00

1 Answers1

1

try this to handle bad lines:

k1=pd.read_table(
r'https://raw.githubusercontent.com/justmarkham/pandas-videos/master/data/chipotle.tsv'
,error_bad_lines=False
)
  • Received following error. URLError: – prvreddy Mar 19 '18 at 06:01
  • 1
    @prvreddy i assume you are working behind a corporate proxy.... you need to set your proxy before you can access external web resources – Kurumi Tokisaki Mar 19 '18 at 06:04
  • @prvreddy Add "https_proxy" and "http_proxy" to you system environment variable, like: http://proxy.XXXX.com:8020... you can check your OS manual to see how to add environment variables and you IT department for the proxy address. After adding, you need to restart your python to enable the proxy. – Kurumi Tokisaki Mar 19 '18 at 06:15