#NEWLINE# def get_from_db( run , stock , r ) : #NEWLINE# #INDENT# rows = get_all_row ( first_time , r ) #NEWLINE# first_time = rows [ 0 ] [ 0 ] [ 0 : 19 ] #NEWLINE# with open ( ( 'data/%s-%s-at-%s.csv' % ( run , stock , first_time ) ) , 'w+' ) as f : #NEWLINE# #INDENT# f . write ( 'time,price,bid,ask\n' ) #NEWLINE# f . close ( ) #NEWLINE# #UNINDENT# with open ( ( 'data/%s-%s-at-%s.csv' % ( run , stock , first_time ) ) , 'a' ) as f : #NEWLINE# #INDENT# for each in rows : #NEWLINE# #INDENT# f . write ( ( '%s,%s,%s,%s\n' % ( each [ 0 ] , each [ 1 ] , each [ 2 ] , each [ 3 ] ) ) )