Home > Software design >  How to get data from excel cell but not the format in Python?
How to get data from excel cell but not the format in Python?

Time:04-04

I am new to Python. I want to ask that how to get cell data from excel but not the format? enter image description here

The code to get sum of the each row. You may edit according to your requirement.

import csv
import sys, datetime, time
import re
from openpyxl import load_workbook
import openpyxl
import time

i = 1

with open("test_numbers.csv") as file:
    csvreader = csv.reader(file)

    for row in csvreader:
        row_l = row[0].split(";")
        #print(row_l)
        if (row_l[0] or row_l[1]).isdigit():
            print(f"The result for row{i} = {int(row_l[0]) int(row_l[1])}")
            i = i   1
        else:
            i = i   1

The code's output:

enter image description here

CodePudding user response:

Load the excel sheet using the data_only attribute

wb = load_workbook('example.xlsx', data_only=True)
  • Related