随机化样本文件创建(Python 2.6)

时间:2013-11-28 16:40:55

标签: python-2.7

我正在创建一个程序来生成测试数据。目前,这是一个单独的样本文件并将其复制,但是我希望能够获取多个不同的样本并复制这些样本,以便我在测试数据中有更广泛的样本。

printlistfile = open(csvfile, "w")
printlistfile.write ('"TABLE_NAME","FILENAME","R_ID","B_CD","W_DATE"\r')

# Create copies of file & rename*
loop = 1

for loop in xrange (1,(int(totaloutput)+1)):
   prefix = str(loop).zfill(6)
   filename = filenamestart + str(prefix) + filenameend
   filenamecsv = filenamestart + str(prefix)
   outputname = os.path.join(outputdir, filename)
   # write lines to CSV
   printlistfile.write ('"RPMACCUMULATE","' + filenamecsv + '","PLN1003O","0003301","' + today+'"\r')
   # write new test file
   shutil.copyfile("UKH1.ACRMQH1A.ACRMQH1A.PLN1003O.12026.00000000000.RPM", outputname)
   print loop
   loop = loop + 1

printlistfile.close()

0 个答案:

没有答案