diff options
Diffstat (limited to 'app/birds/aba_importer.py')
-rw-r--r-- | app/birds/aba_importer.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/birds/aba_importer.py b/app/birds/aba_importer.py new file mode 100644 index 0000000..e5df528 --- /dev/null +++ b/app/birds/aba_importer.py @@ -0,0 +1,17 @@ +for row_index in range(sheet.nrows): + if sheet.cell(row_index,0).value != '': + sci = sheet.cell(row_index, 0).value.split("(")[1].split(")")[0] + bc = BirdClass.objects.get(scientific_name__exact=sci) + common_name = sheet.cell(row_index, 1).value + sci_name = sheet.cell(row_index, 2).value + code = int(sheet.cell(row_index, 3).value) + bclass = bc + #create bird here + b, created = Bird.objects.get_or_create( + common_name = common_name, + scientific_name = sci_name, + code = code, + bird_class = bc + ) + print(b) + |