我带来的数据是MQTT .转储必须通过MQTT代理。做完json.loads之后,我将得到这些数据作为回报。
[['date here', '1713180'], ['date here', '1713181'], ['date here', '1713182'], ['date here', '1713183'], ['date here', '1713184']]在CSV编写方面,我尝试过许多其他线程,但是我完全不知道如何将它正确地写到csv中。
发布于 2019-04-22 14:31:20
简单地说:
import pandas as pd
df=pd.DataFrame([['date here', '1713180'], ['date here', '1713181'], ['date here', '1713182'], ['date here', '1713183'], ['date here', '1713184']])
df.columns=['timestamp','data']
df.to_csv('test.csv',columns=['timestamp','data'],index=False)发布于 2019-04-22 14:27:33
“你可以使用熊猫:
如果您没有安装熊猫,请运行以下命令来安装它:
pip install pandas然后,您可以使用:
import pandas as pd
data = [['date here', '1713180'], ['date here', '1713181'], ['date here', '1713182'], ['date here', '1713183'], ['date here', '1713184']]
df = pd.DataFrame(data)
df.to_csv("path/to/file.csv")https://stackoverflow.com/questions/55795906
复制相似问题