wangdx25 commited on
Commit
118ae6b
·
verified ·
1 Parent(s): 14ceedc

Add a runnable TsFile Usage example

Browse files
Files changed (1) hide show
  1. README.md +28 -4
README.md CHANGED
@@ -48,10 +48,34 @@ A [LeRobot](https://github.com/huggingface/lerobot) robot-manipulation dataset.
48
 
49
  Camera video streams are **not** included in this repository; see the original dataset for the videos: https://huggingface.co/datasets/LSY-lab/libero_plus_spatial_noise_all_iiwa_failures (`videos/` directory). The numeric state/action series are complete; join with the original videos via `episode_index` + `frame_index`.
50
 
51
- ## Usage
52
-
53
- Read the `.tsfile` files with the Apache TsFile Java or Python SDK.
54
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  ## Source & license
56
 
57
  - Original dataset: https://huggingface.co/datasets/LSY-lab/libero_plus_spatial_noise_all_iiwa_failures
 
48
 
49
  Camera video streams are **not** included in this repository; see the original dataset for the videos: https://huggingface.co/datasets/LSY-lab/libero_plus_spatial_noise_all_iiwa_failures (`videos/` directory). The numeric state/action series are complete; join with the original videos via `episode_index` + `frame_index`.
50
 
51
+ ## Usage
52
+
53
+ Install the Apache TsFile Python SDK (`pip install tsfile`) and read a converted file:
54
+
55
+ ```python
56
+ from pathlib import Path
57
+ from tsfile import TsFileReader
58
+
59
+ path = Path("data/libero_plus_spatial_noise_all_iiwa_failures.tsfile")
60
+ with TsFileReader(str(path)) as reader:
61
+ schemas = reader.get_all_table_schemas()
62
+ print("tables:", list(schemas))
63
+ table_name = next(iter(schemas))
64
+ table = schemas[table_name]
65
+ columns = [column.get_column_name() for column in table.get_columns()]
66
+ print("columns:", columns)
67
+ field_names = [
68
+ column.get_column_name()
69
+ for column in table.get_columns()
70
+ if column.get_column_name() not in {"Time", "time"}
71
+ ]
72
+ if field_names:
73
+ with reader.query_table(table_name, field_names[:3], batch_size=1024) as result:
74
+ batch = result.read_arrow_batch()
75
+ if batch is not None:
76
+ print(batch.to_pandas().head())
77
+ ```
78
+
79
  ## Source & license
80
 
81
  - Original dataset: https://huggingface.co/datasets/LSY-lab/libero_plus_spatial_noise_all_iiwa_failures