Check out example codes for "ros2 bag to csv". It will help you in understanding the concepts better.

Code Example 1

ros2 bag play rosbag2_2020_10_05-10_57_19/

ros2 topic echo --csv /xavier/xy_theta_aruco_position > record1.csv

Learn ReactJs, React Native from akashmittal.com