Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88150

How to create Python code to read data from Excel file and create XML files

$
0
0

I need help with creation of Python code to Create XML's using data in an Excel sheet. I am not a Python expert. I tried to create a piece of code below. The code just reads data from Excel but I am not sure how to write a code to convert that into an XML format.

The column in the Excel represents XML tags and rows represent unique data points

The code needs to create multiple XML files using the data points in the Excel file

Please find the code below. I have tried multiple things but couldn't complete the code.

 import xlrd

 ExcelFileName= 'Data.xlsx'
 workbook = xlrd.open_workbook(ExcelFileName)
 worksheet = workbook.sheet_by_name("Sheet1")
 num_rows = worksheet.nrows
 num_cols = worksheet.ncols
 result_data = []

 for curr_row in range(0, num_rows, 1):
     row_data = []

     for curr_col in range(0, num_cols, 1):
         data = worksheet.cell_value(curr_row, curr_col)
         print(data)
         row_data.append(data)

     result_data.append(row_data)

Viewing all articles
Browse latest Browse all 88150

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>