<s> import urllib <EOL> import csv <EOL> def correctToBillions ( item ) : <EOL> if item . endswith ( '<STR_LIT:M>' ) : <EOL> return float ( item [ : - <NUM_LIT:1> ] ) / <NUM_LIT:1000> <EOL> elif item . endswith ( '<STR_LIT:B>' ) : <EOL> return item [ : - <NUM_LIT:1> ] <EOL> else : <EOL> return item <EOL> items = [ <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT:y>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT:r>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT:e>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT:k>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ] <EOL> params = '<STR_LIT>' . join ( [ x [ <NUM_LIT:0> ] for x in items ] ) <EOL> url = '<STR_LIT>' <EOL> edgar = '<STR_LIT>' <EOL> reader = csv . reader ( open ( '<STR_LIT>' ) ) <EOL> outrows = [ row for row in reader ] <EOL> symbols = [ row [ <NUM_LIT:0> ] for row in outrows [ <NUM_LIT:1> : ] ] <EOL> outrows [ <NUM_LIT:0> ] += [ item [ <NUM_LIT:1> ] for item in items ] + [ '<STR_LIT>' ] <EOL> for idx in range ( <NUM_LIT:0> , len ( symbols ) , <NUM_LIT:20> ) : <EOL> query = url + '<STR_LIT>' + '<STR_LIT:+>' . join ( symbols [ idx : idx + <NUM_LIT:20> ] ) + '<STR_LIT>' + params <EOL> fo = urllib . urlopen ( query ) <EOL> tmpcsv = csv . reader ( fo ) <EOL> rows = [ row for row in tmpcsv ] <EOL> for count , row in enumerate ( rows ) : <EOL> realidx = idx + count + <NUM_LIT:1> <EOL> row = [ x . replace ( '<STR_LIT>' , '<STR_LIT>' ) for x in row ] <EOL> row [ <NUM_LIT:7> ] = correctToBillions ( row [ <NUM_LIT:7> ] ) <EOL> row [ <NUM_LIT:8> ] = correctToBillions ( row [ <NUM_LIT:8> ] ) <EOL> row . append ( edgar + symbols [ realidx - <NUM_LIT:1> ] ) <EOL> outrows [ realidx ] = outrows [ realidx ] + row <EOL> print ( '<STR_LIT>' % ( idx + <NUM_LIT:20> ) ) <EOL> fo = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> writer = csv . writer ( fo , lineterminator = '<STR_LIT:\n>' ) <EOL> writer . writerows ( outrows ) <EOL> fo . close ( ) </s>
