67 lines
1.3 KiB
Plaintext
67 lines
1.3 KiB
Plaintext
|
{
|
||
|
"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
|
||
|
}
|