Issue
This code accepts BTC, ICX,..... inputs one at a time and i would to make accept multiple inputs and output multiple files with the same name as the input. How can i do it?
eg. ETH,ICX, ALG...
Edit: i would like to give n currencies.
from cryptocmd import CmcScraper
currency = input("enter currency:")
date_from = input("enter begining date")
date_to = input ("enter end date")
# initialise scraper with time interval
if date_from and date_to:
scraper = CmcScraper(currency, date_from, date_to)
else:
scraper = CmcScraper(currency)
# get raw data as list of list
headers, data = scraper.get_data()
# get data in a json format
json_data = scraper.get_data("json")
# export the data to csv
scraper.export("csv")
# get dataframe for the data
df = scraper.get_dataframe()
Solution
If you want to give multiple values in a single input
, you can use split
to separate each input and use a for
loop to iterate over each one:
currency_n = input("enter currency:")
date_from = input("enter begining date")
date_to = input ("enter end date")
for currency in currency_n.split(" "):
# initialise scraper with time interval
if date_from and date_to:
scraper = CmcScraper(currency, date_from, date_to)
else:
scraper = CmcScraper(currency)
...
Answered By - Tzane
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.