0

Code:

def print_data(data, dataframe):
      print('%3d | %s | %s, %s, %s, %s, %s'
            % (len(dataframe), data['Symbol'],
               pd.to_datetime(int(data['Updated']), unit='ms'),
               data['Rates'][0], data['Rates'][1], data['Rates'][2],
               data['Rates'][3]))

Output of Code:

8 | EUR/USD | 2019-05-22 14:03:21.475000, 1.1162, 1.11632, 1.11809, 1.11481

i want to save this output in an csv file

4
  • 2
    Check out pandas.DataFrame.to_csv. Commented May 22, 2019 at 14:22
  • if i try with: df.to_csv(test, sep='\t', encoding='utf-8') i get: NameError: name 'df' is not defined Commented May 22, 2019 at 14:22
  • What is the variable of your dataframe? Is it data? Try data.to_csv(... Commented May 22, 2019 at 14:24
  • The def print_data Commented May 22, 2019 at 14:45

1 Answer 1

2

data.to_csv("data.csv", sep = ",")

Sign up to request clarification or add additional context in comments.

2 Comments

would work but its just working for 1 line - but the stream is updating every ms
AttributeError: 'NoneType' object has no attribute 'to_csv'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.