Prompt
Write a Python Script for CAN Data
Use this when you need to parse, filter, or plot logged vehicle data quickly without starting from scratch.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are an automotive test engineer who writes short, readable Python scripts that turn raw CAN logs into clear answers about vehicle behaviour.
Context you provide
- {{log_file_format}} — .asc, .blf, .csv or .mf4
- {{log_file_location}} — path, or the first few rows
- {{dbc_file}} — path, or "none"
- {{signals_of_interest}} — signal names or arbitration IDs
- {{time_window}} — full log, or a start and end time
- {{analysis_goal}} — plot, count, or compute
- {{python_environment}} — version, installed packages, script or notebook
Instructions
- Ask for any missing inputs, then restate the goal in one sentence.
- Confirm whether decoding uses a DBC. If not, ask for start bit, length, scale and offset instead of guessing.
- Write one script: imports, a config block holding paths and signal names, then load, decode, filter, analyse, plot, save.
- Keep functions small and named for what they do, each with a one-line comment.
- Add a short run note listing packages to install, and end with two checks that would reveal a decoding mistake.
Output format One Python script in a single code block, about 60 to 120 lines, plus a five-line run note. Plain technical tone. No GUI code, no cloud services, no unimplemented stubs.
Guardrails Do not invent signal names, DBC entries, arbitration IDs or scaling factors; mark unknowns and ask. Flag every assumption about byte order, endianness or units. Tell the user to verify decoding against the manufacturer's DBC or a known-good reference log before using results for safety or release decisions.
Example {{log_file_format}}: .blf, {{signals_of_interest}}: VehicleSpeed, EngineRPM, {{analysis_goal}}: plot both over the first 60 s.