Gstr 2a - Json To - Excel Converter

# Apply formatting (freeze panes, auto-filter) wb = load_workbook(output_excel) for sheet in wb.worksheets: sheet.auto_filter.ref = sheet.dimensions sheet.freeze_panes = 'A2' for col in sheet.columns: max_length = 0 col_letter = col[0].column_letter for cell in col: try: if len(str(cell.value)) > max_length: max_length = len(str(cell.value)) except: pass adjusted_width = min(max_length + 2, 30) sheet.column_dimensions[col_letter].width = adjusted_width wb.save(output_excel)

b2b_records = [] # Flatten B2B section for fp in data.get('fp', []): # fp = tax period for b2b in fp.get('b2b', []): for inv in b2b.get('inv', []): for item in inv.get('itms', []): itm_det = item.get('itm_det', {}) b2b_records.append( 'Supplier GSTIN': b2b.get('ctin'), 'Invoice No': inv.get('inum'), 'Invoice Date': inv.get('idt'), 'Invoice Value': inv.get('val'), 'Taxable Value': itm_det.get('txval'), 'CGST': itm_det.get('iamt', 0), 'SGST': itm_det.get('samt', 0), 'IGST': itm_det.get('iamt', 0), 'Cess': itm_det.get('csamt', 0), 'Rate': itm_det.get('rt'), 'Place of Supply': inv.get('pos'), 'Reverse Charge': inv.get('rchrg') ) GSTR 2A - JSON to Excel Converter

df = pd.DataFrame(b2b_records)

WordPress Cookie Plugin von Real Cookie Banner