import json
import xlrd
import re
wb=xlrd.open_workbook("Preposition2.xlsx")
sheet=wb.sheet_by_name("Sheet1")
node=[]
qid=1
def options(r):
    op=[]
    for i in range(6,10):
        op.append(str(sheet.cell_value(r,i)).strip())
    return op
for r in range(1,sheet.nrows):
    node.append({
                "questionId": qid,
                "sentence": sheet.cell_value(r,1).strip(),
                "correctSentence": sheet.cell_value(r,2).strip(),
                "HindiSentence": sheet.cell_value(r,3).strip(),
                "correctAnswer": sheet.cell_value(r,4).strip(),
                "wrongoption": sheet.cell_value(r,5).strip(),
                "optionArr": options(r),
         })
    qid+=1
with open("Data.json", 'w', encoding='utf-8') as outfile:
    json.dump(node, outfile, indent=4, ensure_ascii=False)
