Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import numpy as np
  2.  
  3. class Parser():
  4.  
  5.     """ Base class for parsers specific to a table format. Explicitly defines methods and attributes the
  6.    subclasses must implement """
  7.     def __init__(self):
  8.         self.defines = {}
  9.         self.labels = []
  10.         self.header = ''
  11.         self.matrix = None
  12.    
  13.  
  14. class ArchicadParser(Parser):
  15.  
  16.     """ Class that parses the archicad table with areas by story for each unit """
  17.  
  18.     def __init__(self, table_fp):
  19.         clean = lambda name : name.replace(' ', '_').lower()
  20.         with open(table_fp, 'r') as f:
  21.             self.texble = [line[:-2].split('\t') for line in f.readlines()]
  22.         self.header = self.texble[0]
  23.         self.body = self.texble[1:]
  24.         self.header = [clean(name) for name in self.header]
  25.         self.matrix = np.array(self.body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement