Excel Macro: Removing the titles and only copying the items -
so know how copy values , paste sheet , removing blank cells how remove titles (the id, item, item number) when paste items on sheet won't have multiple titles
i developed function gets 'header' of file. written csv module, think reworked deal excel. need deal fact there multiple headers. have added while
statement deal this. here function:
def getheader(file): import csv headername = none charlist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '+', "'", '"', '{', '}', '[', ']', '?', '.', ',', '<', '>', '/', '~', '`', '-', '_'] rowcount = 0 headercsv = open(file, 'r', newline = '') headerreader = csv.reader(headercsv, delimiter = ',') while rowcount < 5: row in headerreader: rowcount += 1 if row[0][0] in charlist , row[1][0] in charlist: headername = row headercsv.close() return headername
i call setting variable equal it: thisheader = getheader('filename')
then implement in code doing (i'm using csv module example- i'm familiar with):
for row in csvreader: if row == thisheader: continue else: <get data>
additionally, can use thisheader
write first row in excel spreadsheet, don't need keep dealing it.
hope helps!
Comments
Post a Comment