-1

I need a program to take input from an xlsv file and modify them according to the requirements and them that modified output should be printed in another excel sheet

Up to now, I've done by giving input manually

p=input ("Enter ingredients")
q=input ("enter usage")
r=input ("enter best before")
s=input ("enter description")
p10=p.replace(",","</li>\\n <li>")
p1 ="<Strong>Ingredients:</strong>\\n<ul>\\n<li>"+ p10
p1.replace(",","</li>\\n <li>")
q1="</li>\\n</ui>\n<strong>"+q+"\\n\\n"
r1= r+"<!..more..>\\n\\n"
s1 = s
print = p1+q1+r1+s1

import xlwt 
  
workbook = xlwt.Workbook()  
  
sheet = workbook.add_sheet("Sheet Name") 
 
style = xlwt.easyxf('font: bold 1') 
 
sheet.write(1, 9, print) 
workbook.save("sample1.xls")
  • You probably don't want to be assigning a string to print. Also, what is your question? I see you need to do something, and you've written some code to try to do it. What's not working or what don't you understand? – user2263572 Sep 03 '20 at 01:39
  • that code is working but I want to take inputs directly from a excelsheet – Saiteja Sep 03 '20 at 01:40
  • rather than giving inputs manually – Saiteja Sep 03 '20 at 01:41
  • Use code like `p = Worksheets("Ingredients").Cells(3, "A").Value` where "Ingredients" is the tab name, 3 is a row number and "A" the column. – Variatus Sep 03 '20 at 01:48

1 Answers1

0

You can use xlrd to read excel values in python (xlrd is not part of the standard python library, and will need to be installed)

import xlrd

# get workbook
book = xlrd.open_workbook("example.xls")

# get first worksheet
sheet = book.sheet_by_index(0)

# get cell value
a1 = sheet.cell_value(rowx=0, colx=0)

# print value
print(a1)
user2263572
  • 5,435
  • 5
  • 35
  • 57