"device",
"value",
"refdes",
+ "loadstatus"
};
bool has_header_member(string member) {
return entry["vendor_part_number"];
}
-void process_seeed(string[string] entry)
+string quoted(string v)
{
+ if (String::index(v, "\"") >= 0 || String::index(v, ",") >= 0) {
+ if (String::index(v, "\"") >= 0) {
+ string ret = "\"";
+ for (int i = 0; i < String::length(v); i++) {
+ if (v[i] == '"')
+ ret = ret + "\"";
+ ret = ret + String::new(v[i]);
+ }
+ ret = ret + "\"";
+ return ret;
+ } else {
+ return "\"" + v + "\"";
+ }
+ } else {
+ return v;
+ }
+}
- if (entry["loadstatus"] != "smt")
+void process_seeed(string[string] entry)
+{
+ if (entry["loadstatus"] == "noload")
return;
static bool start = true;
if (start) {
- printf("Part/Designator,Manufacturer Part Number/Seeed SKU, Quantity");
+ printf("Part/Designator,Manufacturer Part Number/Seeed SKU, Quantity\n");
start = false;
}
}
if (dim(refdes) > 1)
printf ("\"");
- printf(",%s,%s\n", entry["mfg_part_number"], entry["quantity"]);
+ printf(",%s,%s\n", quoted(entry["mfg_part_number"]), entry["quantity"]);
}
void process_digikey(string[string] entry)
{
+ if (entry["loadstatus"] == "noload")
+ return;
printf("%s,%s,%s %s\n",
entry["quantity"],
- part_number(entry),
- entry["device"],
- entry["value"]);
+ quoted(part_number(entry)),
+ quoted(entry["device"]),
+ quoted(entry["value"]));
+}
+
+void process_mouser(string[string] entry)
+{
+ if (entry["loadstatus"] == "noload")
+ return;
+/* printf("%s|%s\n", part_number(entry), entry["quantity"]); */
+
+ static bool start = true;
+
+ if (start) {
+ printf("Mouser Part Number,Manufacturer Part Number,Quantity 1\n");
+ start = false;
+ }
+
+ printf("%s,%s,%s\n",
+ quoted(entry["vendor_part_number"]),
+ quoted(entry["mfg_part_number"]),
+ entry["quantity"]);
}
void process_other(string[string] entry) {
+ if (entry["loadstatus"] == "noload")
+ return;
printf("%s,%s,%s,%s %s\n",
entry["vendor"],
entry["quantity"],
- part_number(entry),
- entry["device"],
+ quoted(part_number(entry)),
+ quoted(entry["device"]),
entry["value"]);
}
case "digikey":
process_digikey(entry);
break;
+ case "mouser":
+ process_mouser(entry);
+ break;
default:
process_other(entry);
break;