finviz icon indicating copy to clipboard operation
finviz copied to clipboard

Is there a way to only print the 'Ticker' column to a CSV

Open mmehrle opened this issue 4 years ago • 1 comments

Since your Finviz data list seems to behave differently than a regular python list I am running into issues just printing a list of tickers based on a request.

This is what I'm trying to do:

from finviz.screener import Screener
import nest_asyncio
nest_asyncio.apply()

filter = ["geo_usa", "sh_avgvol_o2000", "sh_opt_optionshort", "sh_price_o30"]
stock_list = Screener(filters=filter, order='volume')
print ("%s symbols listed.\n" % len(stock_list))
tickers = stock_list['Ticker']
tickers.to_csv("tickers.csv")

The last one is breaking and I don't see any pertinent documentation about it telling me how to just grab one column.

Thanks in advance for any pointers.

mmehrle avatar Dec 07 '20 18:12 mmehrle

Might not be the cleanest way, but you could do this.

tickers = [stock["Ticker"] for stock in stock_list]

linuxkd avatar Feb 07 '21 15:02 linuxkd