1

The code works perfectly and generates stocks info until the infinite loop. Python's giving me an error:

data.to_excel("output.xlsx") ^ IndentationError: unexpected indent

I've tried uninstalling and reinstalling pandas but to no avail. Code is below:

import pandas as pd
from alpha_vantage.timeseries import TimeSeries
import time

api_key = 'xxxxxxxxxxxxxxxxx'

ts = TimeSeries(key=api_key, output_format='pandas')
data, meta_data = ts.get_intraday(symbol='MSFT', interval = '1min', outputsize = 'full')
print(data)

i = 1 
while i == 1:
    data, meta_data = ts.get_intraday(symbol='MSFT', interval = '1min', outputsize = 'full')
    data.to_excel("output.csv")
    time.sleep(60)
  • This is probably a duplicated question (https://stackoverflow.com/questions/14979224/indentation-error-in-python) – Stram Apr 23 '20 at 12:36

1 Answers1

0

Check you are not mixing spaces and tabs for indentation. This can sometimes happen unexpectedly when you copy and paste code from different sources

Behzad
  • 123
  • 1
  • 1
  • 11