get_all_tickers: ParserError: Error tokenizing data. C error: Expected 1 fields in line 23, saw 46
When I try:
from get_all_tickers import get_tickers as gt
tickers = gt.get_tickers()
I get an error:
tickers = gt.get_tickers(NASDAQ=False)
---------------------------------------------------------------------------
ParserError Traceback (most recent call last)
c:\Users\Mislav\Documents\GitHub\stocksee\stocksee\ib_market_data.py in
----> 36 tickers = gt.get_tickers(NASDAQ=False)
C:\ProgramData\Anaconda3\lib\site-packages\get_all_tickers\get_tickers.py in get_tickers(NYSE, NASDAQ, AMEX)
71 tickers_list = []
72 if NYSE:
---> 73 tickers_list.extend(__exchange2list('nyse'))
74 if NASDAQ:
75 tickers_list.extend(__exchange2list('nasdaq'))
C:\ProgramData\Anaconda3\lib\site-packages\get_all_tickers\get_tickers.py in __exchange2list(exchange)
136
137 def __exchange2list(exchange):
--> 138 df = __exchange2df(exchange)
139 # removes weird tickers
140 df_filtered = df[~df['Symbol'].str.contains("\.|\^")]
C:\ProgramData\Anaconda3\lib\site-packages\get_all_tickers\get_tickers.py in __exchange2df(exchange)
132 response = requests.get('https://old.nasdaq.com/screening/companies-by-name.aspx', headers=headers, params=params(exchange))
133 data = io.StringIO(response.text)
--> 134 df = pd.read_csv(data, sep=",")
135 return df
136
~\AppData\Roaming\Python\Python38\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, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
674 )
675
--> 676 return _read(filepath_or_buffer, kwds)
677
678 parser_f.__name__ = name
~\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
452
453 try:
--> 454 data = parser.read(nrows)
455 finally:
456 parser.close()
~\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py in read(self, nrows)
1131 def read(self, nrows=None):
1132 nrows = _validate_integer("nrows", nrows)
-> 1133 ret = self._engine.read(nrows)
1134
1135 # May alter columns / col_dict
~\AppData\Roaming\Python\Python38\site-packages\pandas\io\parsers.py in read(self, nrows)
2035 def read(self, nrows=None):
2036 try:
-> 2037 data = self._reader.read(nrows)
2038 except StopIteration:
2039 if self._first_chunk:
pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.read()
pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory()
pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._read_rows()
pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows()
pandas\_libs\parsers.pyx in pandas._libs.parsers.raise_parser_error()
ParserError: Error tokenizing data. C error: Expected 1 fields in line 23, saw 46
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 5
- Comments: 22
Commits related to this issue
- Make `get_tickers_fixed.py` distinguish ecxchanges The supposed 'sane' module taken from this issue [1] is broken. It always returns all tickers even if only a single exchange is selected. This comm... — committed to SuperstonkQuants/q4_majorshortsqueezes by JyzayaEU 3 years ago
- Make `get_tickers_fixed.py` distinguish ecxchanges The supposed 'sane' module taken from this issue [1] is broken. It always returns all tickers even if only a single exchange is selected. This comm... — committed to SuperstonkQuants/q4_majorshortsqueezes by JyzayaEU 3 years ago
Nasdaq API got updated, so the old URL is no longer available I believe.
The following is a quick implementation of the new API.
I made a quick&dirty fix in get_tickers.py. Filtering by mktcap_min, mktcap_max and sectors works for me. I didn’t test regions. Github doesn’t allow me to upload a .py file, so you need to remove the ‘.txt’ ending of this one and replace the corresponding file in the package. get_tickers.py.txt Thanks to @Possums for the basics!
hey @here, as it doesn’t look like the author cares much about this. I’d suggest that somebody that does, and yet doesn’t want to just use the script provided above, create their own repo/fork this with the appropriate modifications.
There’s no point in creating PRs if the author is MIA.
Copy and paste this code to get_tickers.py in your library by searching in your PC where it is. Cheers.
Hey, the “Symbol” column name shall be in all lower case “symbol”
Updated the code by DimaDDM to be able to get individual exchanges rather than return all symbols get_tickers_by_region also updated but untested
get_tickers.py.txt
There is a small typo on the following line:
Simply remove the extra quotation mark at the end. This works @Possums
@patroucheva, You can fix the issue by changing ‘Symbol’ to ‘symbol’ on lines 162 and 163
@ErlerPhilipp Great! The standard way to suggest code changes is to create a pull request, so that might be why you can’t upload a .py file (it’s slightly more work, though).
I am seeing this same issue. I really hope it gets fixed soon!
I am getting the same error. Lets hope it gets fixed. @shilewenuw