merge_machine/preprocess_fields_v3.py
def process_values(self, outputFormat, singleType = False):
		''' Parameters:
			outputFormat either "md" for markdown output, or a separator string for CSV output '''
		self.match_headers_and_values()
		ofs = list()
		fts = dict()
		for (h, f) in self.fields.items():
			lvts = self.likeliest_types(h, f, singleType = True)
			if lvts is None: continue
			fts[h] = lvts
			hofs = uniq(list(itertools.chain.from_iterable([f.normalized_fields(h, lvt) for lvt in lvts])))
			logging.info('Output fields for %s: %s', h, hofs)
			ofs.extend(hofs)
		logging.info('Output fields for all: %s', ofs)
		# Compute new cell values
		b = list()
		for i in range(self.entries):
			l = list()
			for j in range(len(ofs)): l.append(None)
			b.append(l)
		for (h, lvts) in fts.items():
			for lvt in lvts:
				for i, nc in enumerate(f.normalized_values(h, lvt)):
					for (j, of) in enumerate(ofs):
						if of not in nc: continue
						ncs = nc[of] if isinstance(nc[of], list) else [nc[of]]
						b[i][j] = ncs if b[i][j] is None else b[i][j] + ncs
		if outputFormat == 'md':
			# Print timing info
			print('## Temps de traitement')
			print('')
			print('|Classe et méthode|Temps total (ms)|')
			print('|-|-|')
			if len(timingInfo) > 0:
				for k, v in timingInfo.most_common(20):
					print('|{}|{}|'.format(k, str(v)))
			# Print headers
			print('## Résultats de normalisation')
			print('')
			print('|{}|'.format('|'.join(ofs)))
			print('|{}|'.format('|'.join('-' * len(ofs))))
		else:
			print(outputFormat.join(ofs))
		for i in range(self.entries):
			ovs = list([flatten_list(b[i][j]) for j in range(len(ofs))])
			if outputFormat == 'md':
				print('|{}|'.format('|'.join(ovs)))
			else:
				print(outputFormat.join(ovs))
 Parameters:
			outputFormat either "md" for markdown output, or a separator string for CSV output 
outputFormat either "md" for markdown output, or a separator string for CSV output
outputFormat either " md " for markdown output or a separator string for CSV output
def process_values(self, outputFormat, singleType = False):
		self.match_headers_and_values()
		ofs = list()
		fts = dict()
		for (h, f) in self.fields.items():
			lvts = self.likeliest_types(h, f, singleType = True)
			if lvts is None: continue
			fts[h] = lvts
			hofs = uniq(list(itertools.chain.from_iterable([f.normalized_fields(h, lvt) for lvt in lvts])))
			logging.info('Output fields for %s: %s', h, hofs)
			ofs.extend(hofs)
		logging.info('Output fields for all: %s', ofs)
		b = list()
		for i in range(self.entries):
			l = list()
			for j in range(len(ofs)): l.append(None)
			b.append(l)
		for (h, lvts) in fts.items():
			for lvt in lvts:
				for i, nc in enumerate(f.normalized_values(h, lvt)):
					for (j, of) in enumerate(ofs):
						if of not in nc: continue
						ncs = nc[of] if isinstance(nc[of], list) else [nc[of]]
						b[i][j] = ncs if b[i][j] is None else b[i][j] + ncs
		if outputFormat == 'md':
			print('## Temps de traitement')
			print('')
			print('|Classe et méthode|Temps total (ms)|')
			print('|-|-|')
			if len(timingInfo) > 0:
				for k, v in timingInfo.most_common(20):
					print('|{}|{}|'.format(k, str(v)))
			print('## Résultats de normalisation')
			print('')
			print('|{}|'.format('|'.join(ofs)))
			print('|{}|'.format('|'.join('-' * len(ofs))))
		else:
			print(outputFormat.join(ofs))
		for i in range(self.entries):
			ovs = list([flatten_list(b[i][j]) for j in range(len(ofs))])
			if outputFormat == 'md':
				print('|{}|'.format('|'.join(ovs)))
			else:
				print(outputFormat.join(ovs))
def process_values ( self , outputFormat , singleType = False ) : self . match_headers_and_values ( ) ofs = list ( ) fts = dict ( ) for ( h , f ) in self . fields . items ( ) : lvts = self . likeliest_types ( h , f , singleType = True ) if lvts is None : continue fts [ h ] = lvts hofs = uniq ( list ( itertools . chain . from_iterable ( [ f . normalized_fields ( h , lvt ) for lvt in lvts ] ) ) ) logging . info ( 'Output fields for %s: %s' , h , hofs ) ofs . extend ( hofs ) logging . info ( 'Output fields for all: %s' , ofs ) b = list ( ) for i in range ( self . entries ) : l = list ( ) for j in range ( len ( ofs ) ) : l . append ( None ) b . append ( l ) for ( h , lvts ) in fts . items ( ) : for lvt in lvts : for i , nc in enumerate ( f . normalized_values ( h , lvt ) ) : for ( j , of ) in enumerate ( ofs ) : if of not in nc : continue ncs = nc [ of ] if isinstance ( nc [ of ] , list ) else [ nc [ of ] ] b [ i ] [ j ] = ncs if b [ i ] [ j ] is None else b [ i ] [ j ] + ncs if outputFormat == 'md' : print ( '## Temps de traitement' ) print ( '' ) print ( '|Classe et méthode|Temps total (ms)|') print ( '|-|-|' ) if len ( timingInfo ) > 0 : for k , v in timingInfo . most_common ( 20 ) : print ( '|{}|{}|' . format ( k , str ( v ) ) ) print ( '## Résultats de normalisation') print ( '' ) print ( '|{}|' . format ( '|' . join ( ofs ) ) ) print ( '|{}|' . format ( '|' . join ( '-' * len ( ofs ) ) ) ) else : print ( outputFormat . join ( ofs ) ) for i in range ( self . entries ) : ovs = list ( [ flatten_list ( b [ i ] [ j ] ) for j in range ( len ( ofs ) ) ] ) if outputFormat == 'md' : print ( '|{}|' . format ( '|' . join ( ovs ) ) ) else : print ( outputFormat . join ( ovs ) )
Parameters:
outputFormat either "md" for markdown output, or a separator string for CSV output
Parameters : outputFormat either " md " for markdown output or a separator string for CSV output
''' Parameters:
			outputFormat either "md" for markdown output, or a separator string for CSV output ''' # Compute new cell values # Print timing info # Print headers
self
outputFormat
singleType