Apache TsFile Version: 2.2.0: Can Not read the TsFile generated by Apache IoTDB version 2.0.5 (Build: 0917050) with tree model

8 hours ago 1
ARTICLE AD BOX

I have wrote the python code as following:

import tsfile as ts import pandas as pd def read_tsfile(file_path, device_name, sensors): print(f"Reading TsFile from: {file_path}") print(f"Querying data for device: {device_name}, sensors: {sensors}") df = ts.to_dataframe(file_path) print(f"Retrieved DataFrame with shape: {df.shape}") print(f"Columns: {df.columns.tolist()}") print(df.head()) # Filter for the specific device and sensors df = df[df['device'] == device_name] df = df[df['measurement'].isin(sensors)] print(f"After filtering: {df.shape}") # Pivot to wide format df_pivot = df.pivot(index='timestamp', columns='measurement', values='value').reset_index() df_pivot.columns.name = None df_pivot = df_pivot[['timestamp'] + sensors] return df_pivot def write_csv(df, file_path): print(f"Writing DataFrame to CSV at: {file_path}") df.to_csv(file_path, index=False) if __name__ == '__main__': tsfile_path = r"C:\IoTDB\data\datanode\data\sequence\root.sensors\4\2912\1761643915818-1-0-0.tsfile" csv_path = r"C:\IoTDB\output_1.csv" # 替换为你想要保存的CSV路径 device_name = 'root.sensors.TH' sensors = ['t', 'h'] data = read_tsfile(tsfile_path, device_name, sensors) print(f"Data length: {len(data)}") write_csv(data, csv_path) print(f'Converted {tsfile_path} to {csv_path}')

however the result is:

C:\Users\Admin\AppData\Local\Programs\Python\Python311\python.exe e:/dml/tsfile_tree2csv.py

Reading TsFile from: C:\IoTDB\data\datanode\data\sequence\root.sensors\4\2912\1761643915818-1-0-0.tsfile

Querying data for device: root.sensors.TH, sensors: ['t', 'h']

columns name is None, return all columns

The data example in the TsFile

Read Entire Article