KiCadとBOM(マルツに発注)

マルツは、日本にある電子部品の販売店です。彼らは、以下のようなフォーマットのBOMファイルを受け入れます。

どうも、彼らは、Shift_JISエンコーディングされた日本語しか理解しないようです。これは、多少残念なことですが、基本的な考え方は、常に同じです。

# coding: utf-8
import xml.etree.ElementTree as ET
import re

print('"型番","メーカー名","数量"')

tree = ET.parse('RF-ATT.xml')
root = tree.getroot()

regex = r'R[0-9]+'

for node in root.iter('comp'):
	name = node.attrib.get('ref')
	if re.search(regex, name):
		for value in node.iter('value'):
			string = '1/4WキンピR '+value.text+'Ω,KOA,1'
			print(string)

これはpythonのプログラムで、KiCadから出力されるXMLファイル(中間ネットリスト)を、マルツにアップロード可能なBOMファイルに変換します。

% python xml2bom.py | nkf -s > BOM.csv
$ cat BOM.csv | nkf -w
"型番","メーカー名","数量"
1/4WキンピR 1.8KΩ,KOA,1
1/4WキンピR 1.8KΩ,KOA,1
1/4WキンピR 3Ω,KOA,1
1/4WキンピR 910Ω,KOA,1
1/4WキンピR 910Ω,KOA,1
1/4WキンピR 5.6Ω,KOA,1
1/4WキンピR 300Ω,KOA,1
1/4WキンピR 300Ω,KOA,1
1/4WキンピR 18Ω,KOA,1
1/4WキンピR 220Ω,KOA,1
1/4WキンピR 220Ω,KOA,1
1/4WキンピR 24Ω,KOA,1
1/4WキンピR 150Ω,KOA,1
1/4WキンピR 150Ω,KOA,1
1/4WキンピR 39Ω,KOA,1
1/4WキンピR 100Ω,KOA,1
1/4WキンピR 100Ω,KOA,1
1/4WキンピR 75Ω,KOA,1
1/4WキンピR 62Ω,KOA,1
1/4WキンピR 62Ω,KOA,1
1/4WキンピR 240Ω,KOA,1

このBOMファイルをアップロードすると、このようになります。

そして、あなたは今や発注を行なうことが可能です。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.