<s> import os , sys , string , json , csv , time <EOL> from collections import OrderedDict <EOL> from datetime import datetime <EOL> def new_pjson_deactive_stub ( ) : <EOL> ps = OrderedDict ( ) <EOL> ps [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> ps [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> ps [ '<STR_LIT:title>' ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] = OrderedDict ( ) <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT:status>" ] = "<STR_LIT:D>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> return ps <EOL> def new_pjson_stub ( ) : <EOL> ps = OrderedDict ( ) <EOL> ps [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> ps [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> ps [ '<STR_LIT:title>' ] = "<STR_LIT>" <EOL> ps [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> ps [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] = OrderedDict ( ) <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT:status>" ] = "<STR_LIT:A>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT:None>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> ps [ "<STR_LIT>" ] = [ ] <EOL> return ps <EOL> def publiccsv2pjson ( csvfile , output_dir ) : <EOL> """<STR_LIT>""" <EOL> process_start_time = time . time ( ) <EOL> pdir = <NUM_LIT:1> <EOL> try : <EOL> os . mkdir ( output_dir ) <EOL> except : <EOL> pass <EOL> response_dict = OrderedDict ( ) <EOL> fh = open ( csvfile , '<STR_LIT:rb>' ) <EOL> csvhandle = csv . reader ( fh , delimiter = '<STR_LIT:U+002C>' ) <EOL> rowindex = <NUM_LIT:0> <EOL> po_count = <NUM_LIT:0> <EOL> error_list = [ ] <EOL> for row in csvhandle : <EOL> if rowindex == <NUM_LIT:0> : <EOL> rowindex += <NUM_LIT:1> <EOL> column_headers = row <EOL> cleaned_headers = [ ] <EOL> for c in column_headers : <EOL> c = c . replace ( "<STR_LIT:.>" , "<STR_LIT>" ) <EOL> c = c . replace ( "<STR_LIT:(>" , "<STR_LIT>" ) <EOL> c = c . replace ( "<STR_LIT:)>" , "<STR_LIT>" ) <EOL> c = c . replace ( "<STR_LIT:$>" , "<STR_LIT:->" ) <EOL> c = c . replace ( "<STR_LIT:U+0020>" , "<STR_LIT:_>" ) <EOL> cleaned_headers . append ( c ) <EOL> else : <EOL> zip_record = zip ( cleaned_headers , row ) <EOL> record = dict ( zip ( cleaned_headers , row ) ) <EOL> no_blank_zip = [ ] <EOL> for i in zip_record : <EOL> if i [ <NUM_LIT:1> ] : <EOL> no_blank_zip . append ( i ) <EOL> if row [ <NUM_LIT:1> ] : <EOL> p = new_pjson_stub ( ) <EOL> if row [ <NUM_LIT:1> ] == "<STR_LIT:1>" : <EOL> p [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> p [ "<STR_LIT:title>" ] = "<STR_LIT>" % ( row [ <NUM_LIT:6> ] , row [ <NUM_LIT:5> ] ) <EOL> if row [ <NUM_LIT:10> ] : <EOL> p [ "<STR_LIT:title>" ] = "<STR_LIT>" % ( p [ "<STR_LIT:title>" ] , row [ <NUM_LIT:10> ] ) <EOL> elif row [ <NUM_LIT:1> ] == "<STR_LIT:2>" : <EOL> p [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> p [ "<STR_LIT:title>" ] = row [ <NUM_LIT:4> ] <EOL> else : <EOL> p [ '<STR_LIT>' ] [ '<STR_LIT:status>' ] = "<STR_LIT:D>" <EOL> p [ "<STR_LIT:title>" ] = "<STR_LIT>" <EOL> p [ "<STR_LIT>" ] = row [ <NUM_LIT:0> ] <EOL> for i in range ( <NUM_LIT:0> , len ( row ) ) : <EOL> if row [ i ] : <EOL> row [ i ] = row [ i ] . decode ( '<STR_LIT:ascii>' , '<STR_LIT:ignore>' ) <EOL> else : <EOL> row [ i ] = "<STR_LIT>" <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT:8> ] . capitalize ( ) <EOL> p [ "<STR_LIT>" ] [ '<STR_LIT>' ] = row [ <NUM_LIT:6> ] . upper ( ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT:7> ] . upper ( ) <EOL> p [ "<STR_LIT>" ] [ '<STR_LIT>' ] = row [ <NUM_LIT:5> ] . upper ( ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT:9> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT:10> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> if row [ <NUM_LIT> ] in ( True , "<STR_LIT:Y>" , "<STR_LIT:y>" , "<STR_LIT>" ) : <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> else : <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT:4> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT:3> ] <EOL> if p [ "<STR_LIT>" ] [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> if p [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> p [ '<STR_LIT>' ] = int ( datetime ( int ( p [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:6> : <NUM_LIT:10> ] ) , <EOL> int ( p [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> : <NUM_LIT:2> ] ) , <EOL> int ( p [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:3> : <NUM_LIT:5> ] ) , <EOL> <NUM_LIT:0> , <NUM_LIT:0> ) . strftime ( '<STR_LIT:%s>' ) ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> if p [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> p [ '<STR_LIT>' ] = int ( datetime ( int ( p [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:6> : <NUM_LIT:10> ] ) , <EOL> int ( p [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> : <NUM_LIT:2> ] ) , <EOL> int ( p [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:3> : <NUM_LIT:5> ] ) , <EOL> <NUM_LIT:0> , <NUM_LIT:0> ) . strftime ( '<STR_LIT:%s>' ) ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> if row [ <NUM_LIT> ] : <EOL> month = row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> day = row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> year = row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:10> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" % ( year , month , day ) <EOL> if row [ <NUM_LIT> ] : <EOL> month = row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> day = row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> year = row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:10> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" % ( year , month , day ) <EOL> if row [ <NUM_LIT> ] : <EOL> month = row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> day = row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> year = row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:10> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" % ( year , month , day ) <EOL> if row [ <NUM_LIT> ] : <EOL> month = row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> day = row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> year = row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:10> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" % ( year , month , day ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> ao_phone_number = row [ <NUM_LIT> ] . upper ( ) <EOL> ao_phone_number = "<STR_LIT>" % ( ao_phone_number [ <NUM_LIT:0> : <NUM_LIT:3> ] , ao_phone_number [ <NUM_LIT:3> : <NUM_LIT:6> ] , ao_phone_number [ <NUM_LIT:6> : <NUM_LIT:12> ] ) <EOL> if ao_phone_number != "<STR_LIT>" : <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = ao_phone_number <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> clean_basic = OrderedDict ( ) <EOL> for k , v in p [ "<STR_LIT>" ] . items ( ) : <EOL> if v : <EOL> clean_basic [ k ] = v <EOL> p [ "<STR_LIT>" ] = clean_basic <EOL> if row [ <NUM_LIT:11> ] or row [ <NUM_LIT> ] or row [ <NUM_LIT> ] : <EOL> other_name = OrderedDict ( ) <EOL> if row [ <NUM_LIT:11> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT:11> ] . upper ( ) <EOL> if row [ <NUM_LIT:12> ] : <EOL> other_name [ "<STR_LIT:code>" ] = row [ <NUM_LIT:12> ] . upper ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> other_name [ "<STR_LIT:code>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> if row [ <NUM_LIT:15> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT:15> ] . upper ( ) <EOL> if row [ <NUM_LIT:16> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT:16> ] . capitalize ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . capitalize ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> other_name [ "<STR_LIT>" ] = row [ <NUM_LIT> ] <EOL> p [ "<STR_LIT>" ] . append ( other_name ) <EOL> a = OrderedDict ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> if a [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT:30> ] . upper ( ) <EOL> a [ "<STR_LIT:state>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT:32> ] . upper ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" % ( row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:3> ] , row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:6> ] , row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:12> ] ) <EOL> if row [ <NUM_LIT> ] : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" % ( row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:3> ] , row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:6> ] , row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:12> ] ) <EOL> else : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT:30> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT:32> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> p [ '<STR_LIT>' ] . append ( a ) <EOL> a = OrderedDict ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> if a [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT:20> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT:state>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> if row [ <NUM_LIT> ] : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" % ( row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:3> ] , row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:6> ] , row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:12> ] ) <EOL> if row [ <NUM_LIT> ] : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" % ( row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:3> ] , row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:6> ] , row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:12> ] ) <EOL> else : <EOL> a [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT:20> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> a [ "<STR_LIT>" ] = row [ <NUM_LIT> ] . upper ( ) <EOL> p [ '<STR_LIT>' ] . append ( a ) <EOL> taxonomy_code_position = <NUM_LIT> <EOL> primary_taxonomy_position = <NUM_LIT:50> <EOL> license_state_position = <NUM_LIT> <EOL> license_number_position = <NUM_LIT> <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:15> ) : <EOL> if row [ taxonomy_code_position ] : <EOL> taxonomy = OrderedDict ( ) <EOL> taxonomy [ '<STR_LIT:code>' ] = row [ taxonomy_code_position ] <EOL> if row [ primary_taxonomy_position ] in ( "<STR_LIT:Y>" , "<STR_LIT:True>" , True , "<STR_LIT>" ) : <EOL> taxonomy [ '<STR_LIT>' ] = True <EOL> else : <EOL> taxonomy [ '<STR_LIT>' ] = False <EOL> p [ '<STR_LIT>' ] . append ( taxonomy ) <EOL> if row [ license_number_position ] : <EOL> license = OrderedDict ( ) <EOL> mlvs = "<STR_LIT>" % ( row [ license_state_position ] , row [ license_number_position ] ) <EOL> license [ '<STR_LIT:code>' ] = mlvs <EOL> license [ '<STR_LIT:state>' ] = row [ license_state_position ] . upper ( ) <EOL> license [ '<STR_LIT:type>' ] = "<STR_LIT>" <EOL> license [ '<STR_LIT:status>' ] = "<STR_LIT>" <EOL> p [ '<STR_LIT>' ] . append ( license ) <EOL> if row [ license_number_position ] and row [ taxonomy_code_position ] : <EOL> taxonomy_license = OrderedDict ( ) <EOL> taxonomy_license [ '<STR_LIT>' ] = row [ taxonomy_code_position ] <EOL> mlvs = "<STR_LIT>" % ( row [ license_state_position ] , row [ license_number_position ] ) <EOL> taxonomy_license [ '<STR_LIT>' ] = mlvs <EOL> p [ '<STR_LIT>' ] . append ( taxonomy_license ) <EOL> taxonomy_code_position += <NUM_LIT:4> <EOL> primary_taxonomy_position += <NUM_LIT:4> <EOL> license_state_position += <NUM_LIT:4> <EOL> license_number_position += <NUM_LIT:4> <EOL> identifier_position = <NUM_LIT> <EOL> identifier_code_position = <NUM_LIT> <EOL> identifier_state_position = <NUM_LIT> <EOL> identifier_issuer_position = <NUM_LIT> <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:50> ) : <EOL> if row [ identifier_position ] : <EOL> identifier = OrderedDict ( ) <EOL> identifier [ '<STR_LIT>' ] = row [ identifier_position ] <EOL> identifier [ '<STR_LIT:code>' ] = row [ identifier_code_position ] <EOL> identifier [ '<STR_LIT:state>' ] = row [ identifier_state_position ] . upper ( ) <EOL> identifier [ '<STR_LIT>' ] = row [ identifier_issuer_position ] <EOL> p [ '<STR_LIT>' ] . append ( identifier ) <EOL> identifier_position += <NUM_LIT:4> <EOL> identifier_code_position += <NUM_LIT:4> <EOL> identifier_state_position += <NUM_LIT:4> <EOL> identifier_issuer_position += <NUM_LIT:4> <EOL> for i in range ( <NUM_LIT> , <NUM_LIT> ) : <EOL> if row [ i ] : <EOL> code , description = row [ i ] . split ( "<STR_LIT:U+0020>" , <NUM_LIT:1> ) <EOL> tg = { "<STR_LIT:code>" : code , "<STR_LIT:description>" : description } <EOL> p [ '<STR_LIT>' ] . append ( tg ) <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> if not p [ "<STR_LIT>" ] : <EOL> del p [ "<STR_LIT>" ] <EOL> else : <EOL> p = new_pjson_deactive_stub ( ) <EOL> p [ "<STR_LIT>" ] = row [ <NUM_LIT:0> ] <EOL> if row [ <NUM_LIT> ] : <EOL> month = row [ <NUM_LIT> ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> day = row [ <NUM_LIT> ] [ <NUM_LIT:3> : <NUM_LIT:5> ] <EOL> year = row [ <NUM_LIT> ] [ <NUM_LIT:6> : <NUM_LIT:10> ] <EOL> p [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" % ( year , month , day ) <EOL> fn = "<STR_LIT>" % ( p [ "<STR_LIT>" ] ) <EOL> subdir = os . path . join ( output_dir , str ( p [ "<STR_LIT>" ] ) [ <NUM_LIT:0> : <NUM_LIT:4> ] ) <EOL> try : <EOL> os . mkdir ( subdir ) <EOL> except : <EOL> pass <EOL> fp = os . path . join ( subdir , fn ) <EOL> ofile = open ( fp , '<STR_LIT:w>' ) <EOL> ofile . writelines ( json . dumps ( p , indent = <NUM_LIT:4> ) ) <EOL> ofile . close ( ) <EOL> po_count += <NUM_LIT:1> <EOL> if po_count % <NUM_LIT:1000> == <NUM_LIT:0> : <EOL> pdir += <NUM_LIT:1> <EOL> out = "<STR_LIT>" % ( po_count , ( time . time ( ) - process_start_time ) ) <EOL> print out <EOL> rowindex += <NUM_LIT:1> <EOL> if error_list : <EOL> response_dict [ '<STR_LIT>' ] = rowindex - <NUM_LIT:1> <EOL> response_dict [ '<STR_LIT>' ] = len ( error_list ) <EOL> response_dict [ '<STR_LIT>' ] = error_list <EOL> response_dict [ '<STR_LIT:code>' ] = <NUM_LIT> <EOL> response_dict [ '<STR_LIT:message>' ] = "<STR_LIT>" <EOL> else : <EOL> response_dict [ '<STR_LIT>' ] = rowindex - <NUM_LIT:1> <EOL> response_dict [ '<STR_LIT>' ] = rowindex - <NUM_LIT:1> <EOL> response_dict [ '<STR_LIT:code>' ] = <NUM_LIT:200> <EOL> response_dict [ '<STR_LIT:message>' ] = "<STR_LIT>" <EOL> return response_dict <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if len ( sys . argv ) != <NUM_LIT:3> : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> csv_file = sys . argv [ <NUM_LIT:1> ] <EOL> output_dir = sys . argv [ <NUM_LIT:2> ] <EOL> result = publiccsv2pjson ( csv_file , output_dir ) <EOL> print json . dumps ( result , indent = <NUM_LIT:4> ) </s>
