-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extraction based on attributes #428
Comments
looks like a simple function addition for: |
maybe meanwhile you can do some script yourself: import canmatrix.formats
import canmatrix.copy
target = canmatrix.CanMatrix()
cm = canmatrix.formats.loadp_flat("some.dbc")
copy_frames = [f for f in cm.frames if f.attributes.get("YOURATTRIBUTE", "") == "YOURVALUE"]
for frame in copy_frames:
canmatrix.copy.copy_frame(cm, target)
canmatrix.formats.dump({"":target},"out.dbc") Not Tested ! |
thanks for the suggestion. It looks like attribute parsing has some issue with a white space in front of ';' add attributes.get() will not find it. Also, if I remove the white space, the string attribute got appended with an extra " at the end. test case: The following will fail the parsing The following |
thanks for this issue, gonna have a look ... |
I confirm that the white space issue has been fixed by 961918a on branch iss427. |
my code was not handling default values, so here's an update: import canmatrix.formats
import canmatrix.copy
target = canmatrix.CanMatrix()
cm = canmatrix.formats.loadp_flat("some.dbc")
copy_frames = [f for f in cm.frames if f.attribute("YOURATTRIBUTE", cm) == "YOURVALUE"]
for frame in copy_frames:
canmatrix.copy.copy_frame(cm, target)
canmatrix.formats.dump({"":target},"out.dbc") use frame.attribute("YOURATTRIBUTE", matrix) to get the atrribute value or the default. |
Is there anyway to filter/extract frames based on attributes?
python -m canmatrix.cli.convert --attr=my_attribute_name:attr_value source.dbc filtered.dbc
The text was updated successfully, but these errors were encountered: