#!/usr/bin/python3 import os from platform import release import sys import csv # make directory for bom html file and assets dirName = "Feeder-" + sys.argv[1] if not os.path.exists(dirName): os.mkdir(dirName) print("Directory " , dirName , " Created ") else: print("Directory " , dirName , " already exists") # make html file that will become our BOM f = open(dirName + "/bom_" + sys.argv[1] + ".html", "w") f.write("""

""") #write page title based on script f.write("LumenPnP Feeder BOM " + sys.argv[1]) #write the beginning of table, and row for header f.write("

Download the Source Here

") with open('bom.csv') as bom: csv_reader = csv.reader(bom, delimiter=',') line_count = 0 for row in csv_reader: column = 0 if line_count == 0: #if header row, just print what's there f.write("") while column < len(row): f.write("") column += 1 else: #if content row if row[6] != "": f.write("") else: f.write("") while column < len(row): # handling images if column == 1 and row[3] != "FDM": f.write("") elif column == 1 and row[3] == "FDM": f.write("") # handling links elif (column == 4 or column == 5) and row[3] != "FDM" and row[column] != "": f.write("") # all other cells else: f.write("") column += 1 f.write("") line_count += 1 f.write("
" + row[column] + "
Link" + row[column] + "
") f.close()