Joining two rawlog files together
Sometimes you may want to record a dataset (with rawlog-grabber) into a set of separate segments, each in a different rawlog file. Or, perhaps, one sensor failed or the grabber program just crashed for some reason, so you had to continue grabbing into a different file.
In any case, here is how you can join two (or more) rawlog files together, so they can be treated as a single, continuous dataset:
- Prepare: As explained in another tutorial, rawlog files are the binary serialization of sensor data objects. If some file was abruptly interrupted, there is a chance that the last saved object was truncated. Reading a dataset is aborted when such an error is found, so it is mandatory to remove those errors. One easy way to do it is: load all dataset files into RawLogViewer and save them again (overwriting the original ones, or with a different name, as you want). In case there was truncated objects, they will be lost and nothing can be done to avoid it.
- Decompress: Typically, dataset are compressed with gzip as they are saved. Rename the file extensions from “.rawlog” to “.rawlog.gz” and decompress them to retrieve the plain binary files.
- Join: Join the binary files with your favorite tool. In GNU/Linux you can use “cat”:
1$ cat file1.rawlog file2.rawlog > file_all.rawlog
- Compress (optional): Optionally, compress the final file with “gzip”. You can also load and save it from RawLogViewer and the program will automatically compress it while saving.