Skip to content

Abhimanyu07/rosbag2csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

rosbag2csv

Simple utility to export tables from a sqlite3 database (generated from a ROS bag) to CSV.

This repository contains a tiny CLI helper (read_bag.py) that lists tables from a sqlite3 database and exports a selected table to a CSV file.

Features

  • List tables in a sqlite3 database
  • Export a chosen table to <table>.csv (writes header row)

Requirements

  • Python 3.7+
  • Standard library only (no external dependencies)

The script uses the built-in sqlite3 module, argparse, and csv.

Usage

Place your sqlite3 database file (for example, a ROS bag-derived database) somewhere accessible and run the script.

Show available tables:

python3 read_bag.py --db /path/to/your/dbfile.db3 --list

Export a table to CSV (writes TABLE_NAME.csv in the output directory):

python3 read_bag.py --db /path/to/your/dbfile.db3 --table TABLE_NAME --out /path/to/outdir

Notes:

  • If --out is omitted the CSV is written to the current directory.
  • If --db is omitted the script uses a project-local default path embedded in the script; pass --db to select a different database.

Exit codes

The script uses numeric exit codes to indicate error types. Common values:

  • 0: success
  • 1: invalid usage (e.g. missing --table and not using --list)
  • 2: requested table not found or no tables available
  • 3: database file not found
  • 4: could not open database
  • 5: error checking table existence
  • 6: error querying database
  • 7: error writing CSV file

Contributing

Small, focused pull requests are welcome. If you want to:

  • Add unit tests, please use pytest and add a minimal test that runs quickly.
  • Switch to a more ROS-native workflow (for example, using rosbag2 tooling) open an issue first to discuss scope.

TODO

Planned improvements and areas for future work:

  • Decode CDR-serialized message payloads before export: many ROS message fields are stored in CDR (Common Data Representation). Adding a deserialization step will produce human-readable fields that can be written to CSV columns rather than raw binary blobs.
  • Organize CSV outputs by topic: write CSV files grouped by ROS topic (for example, one CSV per topic or topic-named subdirectories) so data from different topics stays separated and easy to consume.
  • Add caching / buffering for large datasets: introduce an in-memory or on-disk cache and batch-writing strategy to improve throughput and reduce memory pressure when exporting large databases.

License

MIT License — see LICENSE (not included). If you want a different license, please open an issue.

Contact

Open issues / pull requests in the project repository.

About

Simple utility to export tables from a sqlite3 database (generated from a ROS bag) to CSV.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages