def get_schema(self, filename):
table_set = self.read_file(filename)<EOL>if table_set is None: <EOL><INDENT>return [] <EOL><DEDENT>row_set = table_set.tables[<NUM_LIT:0>]<EOL>offset, headers = headers_guess(row_set.sample)<EOL>row_set.register_processor(headers_processor(headers))<EOL>row_set.register_processor(offset_processor(offset + <NUM_LIT:1>))<EOL>types = type_guess(row_set.sample, strict=True)<EOL>sample = next(row_set.sample)<EOL>clean = lambda v: str(v) if not isinstance(v, str) else v <EOL>schema = []<EOL>for i, h in enumerate(headers):<EOL><INDENT>schema.append([h,<EOL>str(types[i]),<EOL>clean(sample[i].value)])<EOL><DEDENT>return schema<EOL>
Guess schema using messytables