Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # for my son
- # write by kyoung chip , jang
- #
- def test_db() :
- yield "0x01" , 100 , 210
- yield "0x02" , 300 , 220
- yield "0x03" , 400 , 230
- def write_csv( csvfile ) :
- print(" csvfile = %s " % csvfile )
- w = ['data1,data2,data3']
- with open(csvfile, 'w') as f:
- c = 0
- for data1, data2, data3 in test_db():
- print("data1 = %s " % data1 )
- w.append(
- data1 + ',' + str(data2) + ',' + str(data3)
- )
- c += 1
- if c == 1000:
- f.write('\n'.join(w) + '\n')
- w = []
- c = 0
- if c > 0:
- f.write('\n'.join(w) + '\n')
- f.write('\n')
- print('writen to %s' % csvfile)
- if __name__ == '__main__':
- write_csv('./test.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement