Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- def isEmpty(lst):
- for i in lst:
- if i:
- return False
- return True
- def removeEmpty(tbl):
- for i in tbl:
- if isEmpty(i):
- tbl.remove(i)
- return tbl
- def splitAndSort(column):
- column_tmp = []
- for i in column:
- i = i.replace("+", " ").split(" ")
- i.sort()
- if i.count(''):
- i.remove('')
- if not column_tmp.count(i):
- column_tmp.append(i)
- return column_tmp
- def removeFromCol2(col1, col2):
- for i in col1:
- if col2.count(i):
- col2.remove(i)
- return col2
- table = []
- for i in csv.reader(open("/home/alexander/test/python/input.csv")):
- if not isEmpty(i):
- table.append(i)
- print table
- table = removeEmpty(zip(*table))
- print table
- table = [splitAndSort(i) for i in table]
- print table
- result = [table[0]]
- for i in range(0, len(table)-1):
- result.append(removeFromCol2(table[i], table[i+1]))
- print result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement