just trying to save websockets to CSV's. But it just doesnt make the file. Nothing in the directory. Tried running VScvode as admin, moving folder out of C: drive to documents .. nothing. no csv file, and no error. and no information on the internet about this either.
So i kept stripping down the code to the most basic, and it still wont create the file
The dataframe is in-tact and working, and printing the dataframe gets this :
e E s k
B kline 1659568703134 ETHUSDT 0
L kline 1659568703134 ETHUSDT 920866977
Q kline 1659568703134 ETHUSDT 166707.65228800
T kline 1659568703134 ETHUSDT 1659568739999
V kline 1659568703134 ETHUSDT 103.43430000
c kline 1659568703134 ETHUSDT 1611.00000000
... (continued)
import websocket, json, numpy, pandas
from binance.client import Client
from binance.enums import *
SOCKET = "wss://stream.binance.com:9443/ws/ethusdt@kline_1m/btcusdt@kline_1m"
#lol
def on_open(ws):
print('opened connection')
def on_close(ws):
print('closed connection')
def on_message(ws, message):
df = pandas.read_json(message)
print(df)
df.to_csv('my_new_file.csv')
ws = websocket.WebSocketApp(SOCKET, on_open=on_open, on_close=on_close, on_message=on_message)
ws.run_forever()
CodePudding user response:
Try this:
import os
print(os.getcwd())
This will give you the file directory that the file is currently running on, so you can drop the file there.