How s expression of the file is parsed in kicad?

I am trying to read schematic file and get some details from the schematic file. Is there any easier to way to parse the data directly (like some packages which kicad uses, so that I don’t have to write the parsing code separately).

There is some code to parse them, I think, as part of other projects/plugins. The problem with KiCad’s own parser is that there is currently no stable API. If you want to start over and are using Python or JavaScript, it would probably be best to use a tool like Lark.

1 Like

This may help, though it may not be real quick to dial-in what you want. But, once done (and setup with macro), you won’t need to do it again, just load desired file with the macro.

Using LibreOffice, open a new Spreadsheet, select cell1 and select Open. Locate the Schematic file. Set the Delimiters and what you want (and how you want it manipulated).

Once done, formatted/Edited for Pretty-ness and happy, make it a Libre Macro (simple to do).

Screenshot of the Open panel…

1 Like

I want to use python and use the data for extracting all the symbol reference in the schemaric…

FYI - Parsing a spreadsheet is simple so, once getting your Schematic loaded into the spreadsheet, parse/sort what/how you want.

You can do a ‘Watch-Me-Do’ to create the Macro. Quick example shows my BOM macro doing formatting on a Kicad exported BOM…

But, if you like Python (yuk) go for it!

bom

1 Like

Kicad parser
https://docs.kicad.org/doxygen/namespaceSEXPR.html

I am trying to build external plugin, or else I would use excel sheet (it looks way easy)

Try the sexpdata Python package.

2 Likes

How did it go? Did you manage two write some python code to extract what you needed? If so, can tou share it?

I currently have the need to extract all symbols from a schematic, but also to merge symbol libs and change information like footprint library in symbols in a symbol library. Some of the things can be easily done with find and replace, but others would benifit from a parser. And it would probably be easier with a starting point if available.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.