demoparser2
raw JSON → 0.41.2 verified Sat May 09 auth: no python
A Python library for parsing CS2 (Counter-Strike 2) demo files. It provides fast, low-level access to demo tick data including events, player positions, and game state. Current version: 0.41.2. Weekly releases on PyPI.
pip install demoparser2 Common errors
error FileNotFoundError: [Errno 2] No such file or directory: 'path/to/demo.dem' ↓
cause The demo file path is incorrect or the file does not exist.
fix
Verify the file path. Use an absolute path or ensure the relative path is correct.
error AttributeError: module 'demoparser2' has no attribute 'DemoParser' ↓
cause Incorrect import statement (e.g., 'import demoparser2' instead of 'from demoparser2 import DemoParser').
fix
Use correct import: from demoparser2 import DemoParser
Warnings
breaking API changes between versions 0.2x and 0.4x: many method signatures changed. For example, 'parse_events' now requires 'events' as a keyword argument with a list of event names, not just a string. Also, 'parse_ticks' no longer accepts 'ticks_to_parse' parameter; use 'ticks' instead. ↓
fix Update code to match new API. Review changelog on GitHub for migration details.
deprecated The method 'parse_demo' has been removed in version 0.4.0. Use 'parse_events' and 'parse_ticks' instead. ↓
fix Replace parser.parse_demo() with parser.parse_events(...) and parser.parse_ticks(...).
gotcha Parsing all events or ticks without filtering can be extremely memory-intensive, especially for long demos. Always specify a subset of events or ticks. ↓
fix Use the 'events' and 'ticks' parameters to limit data; parse only what you need.
Imports
- DemoParser wrong
from demoparser import DemoParsercorrectfrom demoparser2 import DemoParser
Quickstart
from demoparser2 import DemoParser
parser = DemoParser('path/to/demo.dem')
events = parser.parse_events(events=['player_death', 'round_start'])
for event in events[:5]:
print(event)
tick_data = parser.parse_ticks(ticks=[0, 1000, 5000])
print(tick_data)