Skip to content

bom csv #27

@createthis

Description

@createthis

In case anyone is interested in generating a bom csv, here is a little diff to sort out the columns and such. I just copy and paste this code into bom.py, above the "Printed:" line, then I generated the BOM, then I cut and pasted the csv into another file and imported into a spreadsheet.

diff --git a/bom.py b/bom.py
index 9ca4639..0b96ddb 100755
--- a/bom.py
+++ b/bom.py
@@ -65,6 +65,35 @@ class BOM:
             print >> file, "%3d" % self.vitamins[part], description

         print >> file
+        print >> file, "CSV:"
+
+        if breakdown:
+            longest = 0
+            for ass in self.assemblies:
+                name = ass.replace("_assembly","")
+                longest = max(longest, len(name))
+            for ass in sorted(self.assemblies):
+                name = ass.replace("_assembly","").replace("_"," ").capitalize()
+               print >> file, " %s|" % name,
+            print >> file
+
+        for part in sorted(self.vitamins):
+            if ': ' in part:
+                part_no, description = part.split(': ')
+            else:
+                part_no, description = "", part
+            if breakdown:
+                for ass in sorted(self.assemblies):
+                    bom = self.assemblies[ass]
+                    if part in bom.vitamins:
+                        file.write("%2d|" % bom.vitamins[part])
+                    else:
+                        file.write("  |")
+            print >> file, "%3d|" % self.vitamins[part], description
+
+
+
+        print >> file
         print >> file, "Printed:"
         for part in sorted(self.printed):
             if breakdown:

Quick and dirty, and not a bit elegant, I know. But maybe it saves someone time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions