-1

I am trying following code.

from zipfile import ZipFile
from openpyxl import load_workbook
from io import BytesIO

zip_path = r"path/to/zipfile.zip"
with ZipFile(zip_path) as myzip:
    with myzip.open(myzip.namelist()[0]) as myfile:
        wb = load_workbook(filename=BytesIO(myfile.read()))
        data_sheet = wb.worksheets[1]
        for row in data_sheet.iter_rows(min_row=3, min_col=3):
            print(row[0].value)

it shows

ValueError: stat: path too long for Windows

Is this possible?

I am trying logic from Using openpyxl to read file from memory

Community
  • 1
  • 1
Rahul
  • 10,830
  • 4
  • 53
  • 88

1 Answers1

0

With xlrd following code works fine.

with ZipFile(zip_path) as myzip:
        with myzip.open(myzip.namelist()[0]) as myfile:
            book = xlrd.open_workbook(file_contents=(myfile.read()))
    sh = book.sheet_by_index(0)
    #your code here
Rahul
  • 10,830
  • 4
  • 53
  • 88