I’d like to modify bom_csv_grouped_by_value_with_fp.py but I have never sow any python code before.
The last command in that file is:
out.writerow([refs, len(group), c.getValue(), c.getPartName(), c.getFootprint(),
c.getFootpint() inserts in output row the tekst “LibName:Footprint”, but I would like to get only “Footprint”.
I suppose I should modify the source to something like this:
footpr=c.getFootprint() - I don’t know if variable have to be defined in any way before
some actions to remove anything up to : from footpr
out.writerow([refs, len(group), c.getValue(), c.getPartName(), footpr,…
How to do it? I believe for some of you it is as simple as 2+2.
Thanks. Simpler then I expected.
I’ve checked. It works as I wonted.
I believe source data are vell defind so there is no possibility that c.getFootprint() would get something different from LibName:footprint. I don’t expect to use : in libname or footprint name.
Based on your example I have written the PCB name as my csv header:
Now I have my csv exactly as I need it, so - I’m happy, but…
Then I thought - there should be simpler ways to manipulate strings which are file paths.
Fast look-through python docs you linked I found “Common pathname manipulations”. But don’t know how to understand it.
For example os.path.dirname(path)
I tried net.getSource().dirname(net.getSource()) but got error which I understand as net.getSource() is not path so can not use .dirname with it.
May be there is some way to tell him to treat my text as path.
And I don’t know what I should put as path parameter in (). It looks second time the same info is needed, but it is not logical - it must be something different, but what.
From that I see I need not to use src_split twice so I need not to use that variable at all and that way my two lines:
are reduced to single one:
I supposed that may be […] are not needed as I have only one element inside (in all other lines there were more than one), but without  my name was devided into single chars
I have tried but got “name ‘os’ is not defined”.
Probably something have to be included in source code before it to tell puthon that I will use os. But I don’t ask for answer. If I will ever find time to learn python I will first read a lot and I think such things will be obvious. My nature is such that I read whole instruction before I use electric cordless kettle.
At that moment I just needed to make a litttle modiffication to bom_csv_grouped_by_value_with_fp.py and I have it done.
After reading all KiCad pdf’s bom generation was the only PCB design step I was afraid if I will be able to do it.
in “Common pathname manipulations” i didn’t noticed anything like .filename.
So I will not experiment how to get the same other way and stop with bom and go to build my libraries as I plan to start to seriously use KiCad.