xbile
xbile

Reputation: 92

How to input in python multiple times, given 'n' inputs?

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()

Upvotes: 0

Views: 676

Answers (1)

Tzane
Tzane

Reputation: 3462

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)

    ...

Upvotes: 1

Related Questions