battery-anomaly-detection/notebooks/read_influxdb_data.ipynb

67 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-08-28 18:24:41 +09:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## import data from InfluxDB\n",
"\n",
"Note: you must run `influxd` in your terminal"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from influxdb import InfluxDBClient\n",
"import pandas as pd\n",
"\n",
"client = InfluxDBClient(host='localhost', port=8086)\n",
"\n",
"client.switch_database('ISS')\n",
"\n",
"query = \"SELECT * FROM \\\"EP_Battery.Thing_HMD8310\\\"\"\n",
"\n",
"result = client.query(query)\n",
"\n",
"points = list(result.get_points())\n",
"\n",
"df = pd.DataFrame(points)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"df.to_csv('output.csv')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}