def generateStats(filename, maxSamples = None,):
<EOL>statsCollectorMapping = {'<STR_LIT:float>':    FloatStatsCollector,<EOL>'<STR_LIT:int>':      IntStatsCollector,<EOL>'<STR_LIT:string>':   StringStatsCollector,<EOL>'<STR_LIT>': DateTimeStatsCollector,<EOL>'<STR_LIT:bool>':     BoolStatsCollector,<EOL>}<EOL>filename = resource_filename("<STR_LIT>", filename)<EOL>print("<STR_LIT:*>"*<NUM_LIT>)<EOL>print("<STR_LIT>" % (filename,))<EOL>dataFile = FileRecordStream(filename)<EOL>statsCollectors = []<EOL>for fieldName, fieldType, fieldSpecial in dataFile.getFields():<EOL><INDENT>statsCollector =statsCollectorMapping[fieldType](fieldName, fieldType, fieldSpecial)<EOL>statsCollectors.append(statsCollector)<EOL><DEDENT>if maxSamples is None:<EOL><INDENT>maxSamples = <NUM_LIT><EOL><DEDENT>for i in range(maxSamples):<EOL><INDENT>record = dataFile.getNextRecord()<EOL>if record is None:<EOL><INDENT>break<EOL><DEDENT>for i, value in enumerate(record):<EOL><INDENT>statsCollectors[i].addValue(value)<EOL><DEDENT><DEDENT>stats = {}<EOL>for statsCollector in statsCollectors:<EOL><INDENT>statsCollector.getStats(stats)<EOL><DEDENT>if dataFile.getResetFieldIdx() is not None:<EOL><INDENT>resetFieldName,_,_ = dataFile.getFields()[dataFile.reset]<EOL>stats.pop(resetFieldName)<EOL><DEDENT>if VERBOSITY > <NUM_LIT:0>:<EOL><INDENT>pprint.pprint(stats)<EOL><DEDENT>return stats<EOL>
Collect statistics for each of the fields in the user input data file and
return a stats dict object.

Parameters:
------------------------------------------------------------------------------
filename:             The path and name of the data file.
maxSamples:           Upper bound on the number of rows to be processed
retval:               A dictionary of dictionaries. The top level keys are the
                      field names and the corresponding values are the statistics
                      collected for the individual file.
                      Example:
                      {
                        'consumption':{'min':0,'max':90,'mean':50,...},
                        'gym':{'numDistinctCategories':10,...},
                        ...
                       }