5 import csv
, time
,random
, sys
6 cols
= ['studyYear', 'studyDbId', 'studyName', 'studyDesign', 'locationDbId', 'locationName', 'germplasmDbId', 'germplasmName', 'germplasmSynonyms', 'observationLevel', 'observationUnitDbId', 'observationUnitName', 'replicate', 'blockNumber', 'plotNumber', 'Variable']
12 def make_row(study
,accession
,base_value
):
14 studyDbId
= str(study
)
15 studyName
= str(random
.random()*1000000)#"Study"+str(study)
17 locationDbId
= "00800"
18 locationName
= "The Moon"
19 germplasmDbId
= accession
20 germplasmName
= "AN"+str(accession
)
21 germplasmSynonyms
= ''
22 observationLevel
= "plot"
23 observationUnitDbId
= "MoonPlanter"+str(accession
)
24 observationUnitName
= "MoonPlanter"+str(accession
)
27 plotNumber
= str(accession
)
28 variable
= str(max(0,base_value
+ random
.randint(-value_wobble
,value_wobble
)))
29 return [studyYear
,studyDbId
,studyName
,studyDesign
,locationDbId
,locationName
,germplasmDbId
,germplasmName
,germplasmSynonyms
,observationLevel
,observationUnitDbId
,observationUnitName
,replicate
,blockNumber
,plotNumber
,variable
]
31 # with open("generated.csv","w") as outfile:
32 writer
= csv
.writer(sys
.stdout
,delimiter
=',',quotechar
='"',quoting
=csv
.QUOTE_ALL
)
35 for accession
in range(accession_count
):
36 base_value
= random
.randint(*value_range
)
37 for study
in range(study_count
):
38 row_list
.append(make_row(study
,accession
,base_value
))
40 writer
.writerows(row_list
)