def process(self): counter=0 while counter < self.stream_size and self.translation_finished == False: Translator.process(self) reader = self.wb.get_sheet_by_name(self.sheet_name) skipfirst = 0 for row in reader.rows: if skipfirst != 0: buf = DataBuffer() start_element = row[0].value #If the row is not empty, populate and push the data buffer if start_element != '' and start_element is not None: for col in row: if col.value != '' and col.value is not None: buf.append(col.value) if self.type == 0: buf.type = self.current_sheet+1 else: but.type = self.current_sheet+6 buf.next_status() self.output_queue.put(buf) #If the row is empty, flip the section finished flag else: self.section_finished = True counter+=1 skipfirst+=1 self.last_read+=self.stream_size self.section_finished = True
def process(self): self.con = lite.connect(self.input_file) with self.con: cur = self.con.cursor() cur.execute("SELECT * FROM {} LIMIT ? OFFSET ?".format(self.table_name), (self.stream_size, self.last_read)) rows = cur.fetchall() self.last_read+=len(rows) if len(rows) < self.stream_size: self.section_finished = True if rows is not None and len(rows) != 0: for row in rows: buf = DataBuffer() for col in row: buf.append(col) if self.type == 0: buf.type = self.current_table+1 else: buf.type = self.current_table+1 buf.next_status() self.output_queue.put(buf) Translator.process(self)
def process(self): print('CSVTranslator Process Called') with open(self.input_file, 'rb') as csvfile: self.reader = csv.reader(csvfile, delimiter=',', quotechar='|') #Counter to reset on next section k=0 #Process Counter j=0 #Last Read i=self.last_read for row in self.reader: if j - i < self.stream_size and j >= i: #Check for the type of the data buffer if row[0] != self.current_type: self.next_section() self.current_type = row[0] print('Current Type set to %s' % (self.current_type)) k=0 else: k+=1 #Create the data buffer buf = DataBuffer() print('Data buffer initialized') skipfirst = 0 for col in row: if skipfirst != 0: buf.append(col) print('%s appended to data buffer' % (col)) skipfirst+=1 buf.type = self.current_type #The buffer has been translated buf.next_status() print('Buffer type set to %s' % (self.current_type)) self.output_queue.put(buf) print('Buffer written to queue') j+=1 self.last_read+=self.stream_size print('Last read set to %s' % (self.last_read))