Take a look at the following documentation pages:
- rosbag can record and play ROS topics. This is the best way to record data if you want to emulate the live system behavior and/or avoid extra code to deal with file I/O.
- You can also read and write point clouds from/to PCD files.