File size: 3,600 Bytes
59575d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
license: mit
task_categories:
- time-series-forecasting
tags:
- tsfile
- timeseries
- time-series
- synthetic
- random
- test-data
- format:tsfile
pretty_name: Random IoT Sensor Readings (TsFile)
configs:
- config_name: default
  data_files:
  - split: train
    path: random_iot_sensor_readings.tsfile
---

# Random IoT Sensor Readings (TsFile)

Apache TsFile version of [`anis-mselmi/random-iot-sensor-readings`](https://huggingface.co/datasets/anis-mselmi/random-iot-sensor-readings).

## Overview

8,000 synthetic minute-level IoT sensor readings (temperature, humidity, pressure, status). Purely random, for testing.

- **Tables:** 1 TsFile table(s), 8,000 rows in total.
  - `random_iot_sensor_readings`: 8,000 rows, 2025-01-01 00:00:00 鈫?2025-01-06 13:19:00 (UTC)

## Schema (TsFile structure)

### `random_iot_sensor_readings.tsfile`

- **Time** (INT64, milliseconds) 鈥?the source `timestamp` column.
- **TAG**: none 鈥?the table is stored as a single device.
- **FIELD** (5): `sensor_id` (string), `temperature_c` (double), `humidity_pct` (double), `pressure_hpa` (double), `status` (string)

## Conversion notes

- One TsFile per source table (1 tables). Tables whose source carries several entities per file are stored as one device per entity.
- Time = the table's own clock column as INT64 milliseconds. The clock columns used here are `timestamp`.
- No column is dropped. Rows that share a timestamp inside one device are ordered by a 1 ms step in stable source order, so calendar columns keep their exact day.

## Usage

> **Read this dataset with the Java SDK.** It is written with the `zstd` compressor. The Apache TsFile Java SDK reads every compressor, but the Python SDK (`pip install tsfile`) implements only `UNCOMPRESSED`, `SNAPPY`, `GZIP` and `LZ4`; opening this file with it yields no rows.

Read a converted file with the Apache TsFile Java SDK (`org.apache.tsfile:tsfile`):

```java
import org.apache.tsfile.file.metadata.IDeviceID;
import org.apache.tsfile.read.TsFileReader;
import org.apache.tsfile.read.TsFileSequenceReader;
import org.apache.tsfile.read.common.Path;
import org.apache.tsfile.read.expression.QueryExpression;
import org.apache.tsfile.read.query.dataset.QueryDataSet;
import org.apache.tsfile.write.schema.MeasurementSchema;

import java.util.ArrayList;
import java.util.List;

String path = "random_iot_sensor_readings.tsfile";
try (TsFileSequenceReader sequenceReader = new TsFileSequenceReader(path);
     TsFileReader reader = new TsFileReader(sequenceReader)) {
    // Devices are enumerated as IDeviceID objects. Tables with TAG columns
    // have multi-segment device ids that cannot be rebuilt from their string
    // form, so always use getAllDevices() rather than getAllDeviceIds().
    for (IDeviceID device : sequenceReader.getAllDevices()) {
        List<Path> paths = new ArrayList<>();
        for (MeasurementSchema schema : reader.getMeasurement(device)) {
            String name = schema.getMeasurementName();
            if (name != null && !name.isEmpty() && !name.equalsIgnoreCase("Time")) {
                paths.add(new Path(device, name, true));
            }
        }
        QueryDataSet dataSet = reader.query(QueryExpression.create(paths, null));
        while (dataSet.hasNext()) {
            System.out.println(dataSet.next());
        }
    }
}
```

## Source & license

- Original dataset: [`anis-mselmi/random-iot-sensor-readings`](https://huggingface.co/datasets/anis-mselmi/random-iot-sensor-readings)
- Source card title: Random IoT Sensor Readings
- License: mit (as declared by the original dataset).