KiField updated

KiField was updated. In addition to schematic and library files, it now handles library description files (.dcm file suffix) so you can do bulk editing of a part library’s part descriptions, keywords and docfiles.

5 Likes

I have just installed this, handy for tidying up the part value where some libraries include voltage rating after the value in the same field.
Any chance of a direct save to .ods as well as the xlsx?

CSV is easily imported/exported with LibreOffice/MSOffice

LibreOffice Calc opens xlsx just fine. The irritation is on saving it suggests saving to ods in preference.
It just seems slightly odd only using a MS format, when so many Kicad users are on Linux and therefore not running Excel

The best thing to do is go to the Github repo and enter an issue requesting the .ods enhancement.

There is a checkbox in LibreOffice save dialog to disable that suggestion of saving in *.ods

I will sign up to Github.
It’s not a big deal, but the work is largely done in modules like pyexcel-ods or Odfpy

Small problem with this - all chinese fabs use excel. They have no idea about open office at all. So, despite being full open software user, Ubuntu, open office and Kicad and eclipse, I like xls format - because I need someone on the other end who can read it…

You can save in MS Excel format from LibreOffice

Yes, exactly.
I was referring to the suggestion to save in ods format. I think it is unnecessary additional work, and possible source for error, why keep the file in both formats?
As the fabs like xls, let’s work in xls, in open office.

So far I have it working on a single sheet and it is great!
Now I have a schematic with 5 sheets. I would like to know if it is possible to use KiField to extract all sheets at once, modify the entries and re-insert all parts to the multiple sheets? If yes, what would be the commands?

Use wildcards for the schematic file names (i.e. *.sch)

It gives me a:
File not found: *.sch.
There are no field values to insert!

My command: kifield -x *.sch -i BOM.csv

What’s your current working directory? Is it the same one where schematic files are located?
Try providing full path to both *.sch and BOM.csv.

What I wrote in command prompt :

cd C:\Hardware\V1.1
kifield -x Power.sch -i BOM_Power.csv /Works/
kifield -x Microcontroller.sch -i BOM_Microcontroller.csv /Works/
kifield -x Memory.sch -i BOM_Memory.csv /Works/
kifield -x .sch -i BOM.csv / throw me the error previously stated */

All 6 sheets of my schematic are in the same folder in C:\Hardware\V1.1

One of my sheets wont play ball like the others though:

kifield -x Audio.sch -i BOM_Audio.csv
 Traceback (most recent call last):
   File "c:\python\python35-32\lib\runpy.py", line 170, in _run_module_as_main
     "__main__", mod_spec)
  File "c:\python\python35-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python\Python35-32\Scripts\kifield.exe\__main__.py", line 9, in <module>
  File "c:\python\python35-32\lib\site-packages\kifield\__main__.py", line 147, in main
    exc_field_names=exc_fields)
  File "c:\python\python35-32\lib\site-packages\kifield\kifield.py", line 974, in kifield
    part_fields_dict = extract_part_fields(extract_filenames, inc_field_names, exc_field_names)
  File "c:\python\python35-32\lib\site-packages\kifield\kifield.py", line 559, in extract_part_fields
    f_part_fields_dict = extraction_functions[f_extension](f, inc_field_names, exc_field_names)
  File "c:\python\python35-32\lib\site-packages\kifield\kifield.py", line 356, in extract_part_fields_from_sch
    sch = Schematic(filename)  # Read in the schematic.
  File "c:\python\python35-32\lib\site-packages\kifield\sch.py", line 130, in __init__
    self.header = f.readline()
  File "c:\python\python35-32\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2702: character maps to <undefined>

I fixed that problem by opening the Audio.sch with Notepad and Save as with encoding in ANSI instead of UTF-8. Not sure why it was in UTF-8…

I still can’t find a way to output all sheets to a single csv though…

Well, under Linux this command works fine for me:
kifield --extract /media/cioma/my/project/pcie2rio/pcb/*.sch --insert /media/cioma/my/project/pcie2rio/pcb/pcie2rio.csv

The wildcards won’t work if you’re running in Windows.

I do have Windows…

I created a .bat file to extract all my schematic sheets to individual CSV. I then have to go through all the individual files and use an other .bat to insert all the CSVs to the appropriate sheets. Not the easiest :frowning:

Wildcards don’t work on Windows, but entering multiple files will. Why not manually list all the .sch files in a single call to kifield and get all the fields in a .csv file? Then edit the .csv and insert it back into all the .sch files in the same way.

1 Like