<jupyter_start><jupyter_text>Correcting points where p_display='true' to p_display="True"Due to an error in the telegraf configuration, some points (around 4 for each sensor) were inserted with the `p_display` tag set to `'true'` rather than `'True'`. This corrects this by searching for those points, reinserting them with the correct tag, and then deleting the points with the old tag. **Note:** The password is not included in this notebook so that it can be commited to Github. Please fill in the empty string in the line below to include the admin password for the InfluxDB server.<jupyter_code>from influxdb import InfluxDBClient

client = InfluxDBClient('aqdata.uksouth.cloudapp.azure.com', 8086, 'admin', '', 'aqdata', ssl=True) 
db_data = client.query('SELECT * FROM "ttn" WHERE "p_display" = \'true\' ')

tag_keys = ['app_id',
'dev_id',
'hardware_serial',
'm_coding_rate',
'm_data_rate',
'm_frequency',
'p_corrected',
'p_display',
'p_version',
'port']
def float_or_none(x):
    if x is None:
        return None
    else:
        return float(x)
float_keys = ['m_latitude', 'm_longitude', 'p_dht22_hum', 'p_dht22_pid',
              'p_dht22_temp', 'p_hpma115s0_pid', 'p_humidity', 'p_int_temp', 'p_load1', 'p_load2', 'p_load3',
              'p_opcn2_pid', 'p_pms5003_pid', 'p_pms7003_pid', 'p_temperature']
data_to_write = []
for point in db_data.get_points():
    tags = {k: point[k] for k in tag_keys}
    tags['p_display'] = True
    
    fields = {k: point[k] for k in point.keys() if k not in tag_keys}
    del fields['time']
    
    for key in float_keys:
        fields[key] = float_or_none(fields[key])
    
    new_point = {'measurement': 'ttn',
                  'tags': tags,
                  'time': point['time'],
                  'fields': fields,
                  }
    data_to_write.append(new_point)
len(data_to_write)
data_to_write[0]
client.write_points(data_to_write)
client.query("drop series from ttn where p_display='true'")<jupyter_output>/Users/robin/anaconda3/envs/breathingspaces/lib/python3.7/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
{'fraction_non_alphanumeric': 0.11940946591402518, 'fraction_numerical': 0.015631784628745114, 'mean_word_length': 4.1086474501108645, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '122652', 'license': 'MIT', 'n_tokens_mistral': 816, 'n_tokens_neox': 775, 'n_words': 214, 'path': 'Alter InfluxDB data.ipynb', 'repo_name': 'robintw/BreathingSpacesCode', 'size': '2303'}