def main(argv): inputfile = '' if len(argv) == 0: bailout() try: opts, args = getopt.getopt(argv, "l:", ["list="]) except getopt.GetoptError: bailout() for opt, arg in opts: if opt in ("-l", "--list"): inputfile = arg if inputfile == '': bailout() elif inputfile not in ['stimuli', 'creators', 'people', 'stimsets', 'stimrefs', 'all']: bailout() for case in switch(inputfile): if case('stimuli'): print 1 break if case('creators'): print 2 break if case('people'): print 10 break if case('stimsets'): print 11 break if case('stimrefs'): print 11 break if case('all'): print "something else!" # No need to break here, it'll stop anyway fields = ('FirstName', 'LastName', 'IDNumber', 'Messages') parser = CSVParser('sample.csv', csvmapper.FieldMapper(fields)) converter = csvmapper.JSONConverter(parser) print converter.doConvert(pretty=True)
import csvmapper parser = csvmapper.CSVParser( '../mappers/record_example.csv', csvmapper.JSONMapper('../mappers/mapper_example.json')) converter = csvmapper.JSONConverter(parser) print converter.doConvert(pretty=True)
def to_json(self, pretty=True): converter = csvmapper.JSONConverter(self.parser) return converter.doConvert(pretty=pretty)