for line in f: if not line.strip(): print('file end') break # print(line) surah_number, ayat_number, *line_text = line.strip().split('|') text = ' '.join(line_text) print('For File ' + edition_id + ' writing line...' + str(line_count)) trans_id = surah_number + '-' + ayat_number translation = Translation() translation.id = edition_id + "_" + trans_id translation.ayah_id = trans_id translation.edition_id = edition_id translation.text = text.strip() translation.ayah_number = line_count translation.save(batch=trans_batch) line_count += 1 count += 1 if (count >= 400): trans_batch.commit() count = 0 print('============Complete=============================') trans_batch.commit()
surah.save() surah = Surah() surah.id = 'surah-2' surah.number = 2 surah.name = 'surah-2-name' surah.english_name = 'surah-2-english-name' surah.number_of_ayahs = 7 surah.revelation_type = 'Mecca' surah.save() # import data for translation translation = Translation() translation.id = 'translation-ayah-1-edition-1' translation.ayah_id = 'ayah-1' translation.ayah_number = 1 translation.edition_id = 'edition-1' translation.text = 'Translation for ayah-1 edition-1' translation.save() translation = Translation() translation.id = 'translation-ayah-1-edition-2' translation.ayah_id = 'ayah-1' translation.ayah_number = 1 translation.edition_id = 'edition-2' translation.text = 'Translation for ayah-1 edition-2' translation.save() translation = Translation() translation.id = 'translation-ayah-2-edition-1'