def _load(self, tree):
filename = tree.load_file[<NUM_LIT:0>]<EOL>if filename[<NUM_LIT:0>] in ['<STR_LIT:">', "<STR_LIT:'>"]:<EOL><INDENT>filename = unwrap(filename)<EOL><DEDENT>if not os.path.exists(filename):<EOL><INDENT>raise Exception("<STR_LIT>" % filename)<EOL><DEDENT>batch = self.connection.batch_write(tree.table)<EOL>count = <NUM_LIT:0><EOL>with batch:<EOL><INDENT>remainder, ext = os.path.splitext(filename)<EOL>if ext.lower() in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>ext = os.path.splitext(remainder)[<NUM_LIT:1>]<EOL>opened = gzip.open(filename, "<STR_LIT:rb>")<EOL><DEDENT>else:<EOL><INDENT>opened = open(filename, "<STR_LIT:r>")<EOL><DEDENT>with opened as ifile:<EOL><INDENT>if ext.lower() == "<STR_LIT>":<EOL><INDENT>reader = csv.DictReader(ifile)<EOL>for row in reader:<EOL><INDENT>batch.put(row)<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif ext.lower() == "<STR_LIT>":<EOL><INDENT>for row in ifile:<EOL><INDENT>batch.put(json.loads(row))<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>while True:<EOL><INDENT>batch.put(pickle.load(ifile))<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT>except EOFError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return count<EOL>
Run a LOAD statement