def main(): parser = OptionParser(usage="usage: %prog [options] directory") parser.add_option("-a", "--activity", action="store", dest="activity", default="", help="Type of activity to record",) parser.add_option("-o", "--output", action="store", dest="output", default="meta.csv", help="Output file",) (options, args) = parser.parse_args() if len(args) != 1: parser.error("wrong number of arguments") # Start parsing if options.activity: activityFolder = findActivityFolder(args[0], options.activity) if activityFolder is None: print("Unable to find activity folder for " + options.activity) return else: activityFolder = args[0] metaData = getDataEntries(activityFolder) gyrodata.writeMetadata(metaData, options.output)
def main(): parser = OptionParser(usage="usage: %prog [options] source") parser.add_option("-c", "--config-file", action="store", dest="config", default="gold.yml", help="Configuration file for filter",) parser.add_option("-o", "--output", action="store", dest="output", default="filtered.csv", help="Output file",) (options, args) = parser.parse_args() if len(args) != 1: parser.error("wrong number of arguments") try: with open(options.config, 'r') as configFile: config = yaml.load(configFile) except IOError: sys.exit("Unable to find configuration file " + options.config) data = gyrodata.readMetadata(args[0]) filteredData = [entry for entry in data if isValidEntry(entry, config)] # filter by person if config['data-filters']['unique']: filteredData = [group.next() for key, group in groupby(filteredData, key=itemgetter('person'))] print("Loaded %d entries!" % (len(filteredData))) gyrodata.writeMetadata(filteredData, options.output)