Nick,
?
Why not use the built in Operations to hold the car inventory? That would be a onetime export to CSV and import to JMRI. Then your script could query that database.
-Ken Cameron, Member JMRI Dev Team