diff --git a/target_csv.py b/target_csv.py index 68a8994..b7dc309 100755 --- a/target_csv.py +++ b/target_csv.py @@ -50,7 +50,7 @@ def get_headers(schema, parent_key=DEFAULT_PARENT_KEY, sep=SEP): def generate_key(parent_key, sep, key): return parent_key + sep + key if parent_key else key -def persist_messages(delimiter, quotechar, messages, destination_path): +def persist_messages(delimiter, quotechar, messages, destination_path, validate_records): state = None schemas = {} key_properties = {} @@ -68,7 +68,8 @@ def persist_messages(delimiter, quotechar, messages, destination_path): raise Exception("A record for stream {}" "was encountered before a corresponding schema".format(o['stream'])) - validators[o['stream']].validate(o['record']) + if validate_records: + validators[o['stream']].validate(o['record']) filename = o['stream'] + '.csv' filename = os.path.expanduser(os.path.join(destination_path, filename)) @@ -144,7 +145,8 @@ def main(): state = persist_messages(config.get('delimiter', ','), config.get('quotechar', '"'), input_messages, - config.get('destination_path', '')) + config.get('destination_path', ''), + config.get('validate_records', True)) emit_state(state) logger.debug("Exiting normally")