Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bom csv #27

Open
createthis opened this issue Dec 25, 2012 · 0 comments
Open

bom csv #27

createthis opened this issue Dec 25, 2012 · 0 comments

Comments

@createthis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant