[{"data":1,"prerenderedAt":1713},["ShallowReactive",2],{"doc:\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python":3,"surround:\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python":1677,"ancestors:\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python":1686,"children:\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python":1691,"related:\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python":1692},{"id":4,"title":5,"body":6,"dateModified":1644,"datePublished":1644,"description":1645,"extension":1646,"faq":1647,"keyword":1656,"kind":1657,"meta":1658,"navigation":160,"path":1667,"seo":1668,"slug":1670,"stem":1671,"topics":1672,"type":1675,"__hash__":1676},"docs\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python\u002Findex.md","Read Strict Open XML Excel Files in Python",{"type":7,"value":8,"toc":1631},"minimark",[9,52,57,88,106,110,398,410,414,538,561,692,696,699,1052,1077,1208,1212,1215,1328,1340,1464,1468,1485,1489,1504,1508,1545,1549,1568,1572,1578,1584,1590,1596,1600,1627],[10,11,12,13,17,18,22,23,26,27,30,31,33,34,37,38,41,42,45,46,51],"p",{},"Excel's ",[14,15,16],"em",{},"Save As"," list contains two formats with the ",[19,20,21],"code",{},".xlsx"," extension: ",[14,24,25],{},"Excel Workbook",", the one almost everyone uses, and ",[14,28,29],{},"Strict Open XML Spreadsheet",". The second is the stricter flavour of the ISO standard behind ",[19,32,21],{},", and some organisations pick it for archiving or by policy. The files look identical in Explorer and open normally in Excel, but most Python libraries cannot read them. pandas with openpyxl reports ",[19,35,36],{},"ValueError: Worksheet index 0 is invalid, 0 worksheets found",", openpyxl on its own loads a workbook with no sheets, and the calamine engine says ",[19,39,40],{},"Cannot detect file format",". Nothing in those messages mentions ",[14,43,44],{},"Strict",", so people suspect a corrupt file. This page shows why the readers fail, how to recognise a Strict workbook in two lines, how to convert it to the ordinary format in memory so pandas reads it, when to use LibreOffice instead, and how to stop such files arriving. It belongs to ",[47,48,50],"a",{"href":49},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002F","Handling Excel File Formats and Conversions",".",[53,54,56],"h2",{"id":55},"prerequisites","Prerequisites",[58,59,64],"pre",{"className":60,"code":61,"language":62,"meta":63,"style":63},"language-bash shiki shiki-themes github-light github-dark-high-contrast","pip install pandas openpyxl python-calamine\n","bash","",[19,65,66],{"__ignoreMap":63},[67,68,71,75,79,82,85],"span",{"class":69,"line":70},"line",1,[67,72,74],{"class":73},"sMTad","pip",[67,76,78],{"class":77},"srMev"," install",[67,80,81],{"class":77}," pandas",[67,83,84],{"class":77}," openpyxl",[67,86,87],{"class":77}," python-calamine\n",[10,89,90,91,94,95,98,99,101,102,105],{},"LibreOffice (",[19,92,93],{},"soffice",") is used for the alternative fix in Step 4. The sample, ",[19,96,97],{},"sales_strict.xlsx",", has the namespaces and conformance flag Excel writes when saving as ",[14,100,29],{},": a ",[14,103,104],{},"Sales"," sheet with three regions.",[53,107,109],{"id":108},"step-1-reproduce-the-errors","Step 1 — Reproduce the errors",[58,111,115],{"className":112,"code":113,"language":114,"meta":63,"style":63},"language-python shiki shiki-themes github-light github-dark-high-contrast","import warnings\nimport pandas as pd\nfrom openpyxl import load_workbook\n\nfor engine in [\"openpyxl\", \"calamine\"]:\n    try:\n        pd.read_excel(\"sales_strict.xlsx\", engine=engine)\n    except Exception as e:\n        print(f\"{engine:\u003C9} {type(e).__name__}: {e}\")\n\nwith warnings.catch_warnings(record=True) as caught:\n    warnings.simplefilter(\"always\")\n    wb = load_workbook(\"sales_strict.xlsx\")\nprint(\"openpyxl sees sheets:\", wb.sheetnames, \"| warning:\", str(caught[0].message)[:60] if caught else None)\n","python",[19,116,117,127,141,155,162,189,198,219,235,291,296,321,332,347],{"__ignoreMap":63},[67,118,119,123],{"class":69,"line":70},[67,120,122],{"class":121},"s-kum","import",[67,124,126],{"class":125},"skGVy"," warnings\n",[67,128,130,132,135,138],{"class":69,"line":129},2,[67,131,122],{"class":121},[67,133,134],{"class":125}," pandas ",[67,136,137],{"class":121},"as",[67,139,140],{"class":125}," pd\n",[67,142,144,147,150,152],{"class":69,"line":143},3,[67,145,146],{"class":121},"from",[67,148,149],{"class":125}," openpyxl ",[67,151,122],{"class":121},[67,153,154],{"class":125}," load_workbook\n",[67,156,158],{"class":69,"line":157},4,[67,159,161],{"emptyLinePlaceholder":160},true,"\n",[67,163,165,168,171,174,177,180,183,186],{"class":69,"line":164},5,[67,166,167],{"class":121},"for",[67,169,170],{"class":125}," engine ",[67,172,173],{"class":121},"in",[67,175,176],{"class":125}," [",[67,178,179],{"class":77},"\"openpyxl\"",[67,181,182],{"class":125},", ",[67,184,185],{"class":77},"\"calamine\"",[67,187,188],{"class":125},"]:\n",[67,190,192,195],{"class":69,"line":191},6,[67,193,194],{"class":121},"    try",[67,196,197],{"class":125},":\n",[67,199,201,204,207,209,213,216],{"class":69,"line":200},7,[67,202,203],{"class":125},"        pd.read_excel(",[67,205,206],{"class":77},"\"sales_strict.xlsx\"",[67,208,182],{"class":125},[67,210,212],{"class":211},"sa561","engine",[67,214,215],{"class":121},"=",[67,217,218],{"class":125},"engine)\n",[67,220,222,225,229,232],{"class":69,"line":221},8,[67,223,224],{"class":121},"    except",[67,226,228],{"class":227},"sP0c6"," Exception",[67,230,231],{"class":121}," as",[67,233,234],{"class":125}," e:\n",[67,236,238,241,244,247,250,254,256,259,262,265,268,271,274,276,279,281,284,286,288],{"class":69,"line":237},9,[67,239,240],{"class":227},"        print",[67,242,243],{"class":125},"(",[67,245,246],{"class":121},"f",[67,248,249],{"class":77},"\"",[67,251,253],{"class":252},"sSjpA","{",[67,255,212],{"class":125},[67,257,258],{"class":121},":\u003C9",[67,260,261],{"class":252},"}",[67,263,264],{"class":252}," {",[67,266,267],{"class":227},"type",[67,269,270],{"class":125},"(e).",[67,272,273],{"class":227},"__name__",[67,275,261],{"class":252},[67,277,278],{"class":77},": ",[67,280,253],{"class":252},[67,282,283],{"class":125},"e",[67,285,261],{"class":252},[67,287,249],{"class":77},[67,289,290],{"class":125},")\n",[67,292,294],{"class":69,"line":293},10,[67,295,161],{"emptyLinePlaceholder":160},[67,297,299,302,305,308,310,313,316,318],{"class":69,"line":298},11,[67,300,301],{"class":121},"with",[67,303,304],{"class":125}," warnings.catch_warnings(",[67,306,307],{"class":211},"record",[67,309,215],{"class":121},[67,311,312],{"class":227},"True",[67,314,315],{"class":125},") ",[67,317,137],{"class":121},[67,319,320],{"class":125}," caught:\n",[67,322,324,327,330],{"class":69,"line":323},12,[67,325,326],{"class":125},"    warnings.simplefilter(",[67,328,329],{"class":77},"\"always\"",[67,331,290],{"class":125},[67,333,335,338,340,343,345],{"class":69,"line":334},13,[67,336,337],{"class":125},"    wb ",[67,339,215],{"class":121},[67,341,342],{"class":125}," load_workbook(",[67,344,206],{"class":77},[67,346,290],{"class":125},[67,348,350,353,355,358,361,364,366,369,372,375,378,381,384,387,390,393,396],{"class":69,"line":349},14,[67,351,352],{"class":227},"print",[67,354,243],{"class":125},[67,356,357],{"class":77},"\"openpyxl sees sheets:\"",[67,359,360],{"class":125},", wb.sheetnames, ",[67,362,363],{"class":77},"\"| warning:\"",[67,365,182],{"class":125},[67,367,368],{"class":227},"str",[67,370,371],{"class":125},"(caught[",[67,373,374],{"class":227},"0",[67,376,377],{"class":125},"].message)[:",[67,379,380],{"class":227},"60",[67,382,383],{"class":125},"] ",[67,385,386],{"class":121},"if",[67,388,389],{"class":125}," caught ",[67,391,392],{"class":121},"else",[67,394,395],{"class":227}," None",[67,397,290],{"class":125},[10,399,400,401,404,405,409],{},"openpyxl opens the package — it is a valid zip — but finds no worksheets, because it looks for elements and relationships in the ",[14,402,403],{},"transitional"," namespaces and the Strict file uses different ones; pandas then asks for sheet 0 of an empty workbook. calamine fails earlier, unable to recognise the package at all. The same \"0 worksheets found\" message also appears for broken relationship paths in some generated files — a different cause with different fixes, covered in ",[47,406,408],{"href":407},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-worksheet-index-0-is-invalid-0-worksheets-found\u002F","Fix \"Worksheet index 0 is invalid, 0 worksheets found\""," — so check which one you have before fixing.",[53,411,413],{"id":412},"step-2-recognise-a-strict-workbook","Step 2 — Recognise a Strict workbook",[58,415,417],{"className":112,"code":416,"language":114,"meta":63,"style":63},"import zipfile\n\ndef is_strict(path):\n    with zipfile.ZipFile(path) as z:\n        workbook = z.read(\"xl\u002Fworkbook.xml\").decode(\"utf-8\", \"replace\")\n    return 'conformance=\"strict\"' in workbook or \"purl.oclc.org\u002Fooxml\" in workbook\n\nprint(\"sales_strict.xlsx:\", is_strict(\"sales_strict.xlsx\"), \"| _transitional.xlsx:\", is_strict(\"_transitional.xlsx\"))\n",[19,418,419,426,430,442,455,481,506,510],{"__ignoreMap":63},[67,420,421,423],{"class":69,"line":70},[67,422,122],{"class":121},[67,424,425],{"class":125}," zipfile\n",[67,427,428],{"class":69,"line":129},[67,429,161],{"emptyLinePlaceholder":160},[67,431,432,435,439],{"class":69,"line":143},[67,433,434],{"class":121},"def",[67,436,438],{"class":437},"s_Opv"," is_strict",[67,440,441],{"class":125},"(path):\n",[67,443,444,447,450,452],{"class":69,"line":157},[67,445,446],{"class":121},"    with",[67,448,449],{"class":125}," zipfile.ZipFile(path) ",[67,451,137],{"class":121},[67,453,454],{"class":125}," z:\n",[67,456,457,460,462,465,468,471,474,476,479],{"class":69,"line":164},[67,458,459],{"class":125},"        workbook ",[67,461,215],{"class":121},[67,463,464],{"class":125}," z.read(",[67,466,467],{"class":77},"\"xl\u002Fworkbook.xml\"",[67,469,470],{"class":125},").decode(",[67,472,473],{"class":77},"\"utf-8\"",[67,475,182],{"class":125},[67,477,478],{"class":77},"\"replace\"",[67,480,290],{"class":125},[67,482,483,486,489,492,495,498,501,503],{"class":69,"line":191},[67,484,485],{"class":121},"    return",[67,487,488],{"class":77}," 'conformance=\"strict\"'",[67,490,491],{"class":121}," in",[67,493,494],{"class":125}," workbook ",[67,496,497],{"class":121},"or",[67,499,500],{"class":77}," \"purl.oclc.org\u002Fooxml\"",[67,502,491],{"class":121},[67,504,505],{"class":125}," workbook\n",[67,507,508],{"class":69,"line":200},[67,509,161],{"emptyLinePlaceholder":160},[67,511,512,514,516,519,522,524,527,530,532,535],{"class":69,"line":221},[67,513,352],{"class":227},[67,515,243],{"class":125},[67,517,518],{"class":77},"\"sales_strict.xlsx:\"",[67,520,521],{"class":125},", is_strict(",[67,523,206],{"class":77},[67,525,526],{"class":125},"), ",[67,528,529],{"class":77},"\"| _transitional.xlsx:\"",[67,531,521],{"class":125},[67,533,534],{"class":77},"\"_transitional.xlsx\"",[67,536,537],{"class":125},"))\n",[10,539,540,541,544,545,548,549,552,553,556,557,560],{},"The workbook part of a Strict file declares ",[19,542,543],{},"conformance=\"strict\""," and uses namespaces under ",[19,546,547],{},"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002F"," instead of ",[19,550,551],{},"http:\u002F\u002Fschemas.openxmlformats.org\u002F",". Both formats share the same zip layout, the same part names such as ",[19,554,555],{},"xl\u002Fworkbook.xml"," and ",[19,558,559],{},"xl\u002Fworksheets\u002Fsheet1.xml",", and the same content types, which is why file-type detection by extension or by zip contents cannot tell them apart and why the readers' errors are so unhelpful. Checking for the flag or the namespaces takes a few milliseconds and needs only the standard library, so a reading job can recognise Strict files up front and either convert them or report them clearly instead of failing with a misleading error.",[562,563,571,572,571,576,571,580,571,587,571,595,571,602,571,609,571,612,571,616,571,621,571,627,571,629,571,634,571,636,571,639,571,642,571,646,571,648,571,652,571,654,571,657,571,660,571,664,571,666,571,670,571,672,571,675,571,678,571,682,571,684,571,688,571,690],"svg",{"viewBox":564,"role":565,"ariaLabelledBy":566,"xmlns":569,"style":570},"4 0 752 208","img",[567,568],"sx-ns-t","sx-ns-d","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;max-width:752px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif","\n  ",[573,574,575],"title",{"id":567},"Transitional and Strict namespaces",[577,578,579],"desc",{"id":568},"The spreadsheet, relationship and drawing namespaces in an ordinary transitional workbook start with schemas.openxmlformats.org. In a Strict workbook the same namespaces start with purl.oclc.org\u002Fooxml, and the workbook part declares conformance strict.",[581,582],"rect",{"x":583,"y":374,"width":584,"height":585,"fill":586},"4","752","208","#ffffff",[581,588],{"x":589,"y":590,"width":591,"height":592,"rx":374,"fill":586,"stroke":593,"style":594},"20.0","16.0","119.9","40.0","var(--line,#cdd5e6)","stroke-width:1px",[581,596],{"x":597,"y":590,"width":598,"height":592,"rx":374,"fill":599,"stroke":600,"style":601},"139.9","300.0","#f0f4ff","var(--brand,#5b5cf0)","stroke-width:1.2px",[603,604,608],"text",{"x":605,"y":606,"style":607},"290.0","41.0","font-size:13px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","transitional (Excel Workbook)",[581,610],{"x":611,"y":590,"width":598,"height":592,"rx":374,"fill":599,"stroke":600,"style":601},"440.0",[603,613,615],{"x":614,"y":606,"style":607},"590.0","strict",[581,617],{"x":589,"y":618,"width":591,"height":619,"rx":374,"fill":620,"stroke":593,"style":594},"56.0","34.0","#e7ebef",[603,622,626],{"x":623,"y":624,"style":625},"32.0","78.0","font-size:12.5px;font-weight:700;fill:var(--text,#172033);text-anchor:start","spreadsheet",[581,628],{"x":597,"y":618,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,630,633],{"x":605,"y":631,"style":632},"77.0","font-size:11.5px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","openxmlformats.org\u002F…\u002Fspreadsheetml",[581,635],{"x":611,"y":618,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,637,638],{"x":614,"y":631,"style":632},"purl.oclc.org\u002Fooxml\u002Fspreadsheetml",[581,640],{"x":589,"y":641,"width":591,"height":619,"rx":374,"fill":620,"stroke":593,"style":594},"90.0",[603,643,645],{"x":623,"y":644,"style":625},"112.0","relationships",[581,647],{"x":597,"y":641,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,649,651],{"x":605,"y":650,"style":632},"111.0","openxmlformats.org\u002F…\u002Frelationships",[581,653],{"x":611,"y":641,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,655,656],{"x":614,"y":650,"style":632},"purl.oclc.org\u002F…\u002Frelationships",[581,658],{"x":589,"y":659,"width":591,"height":619,"rx":374,"fill":620,"stroke":593,"style":594},"124.0",[603,661,663],{"x":623,"y":662,"style":625},"146.0","drawing",[581,665],{"x":597,"y":659,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,667,669],{"x":605,"y":668,"style":632},"145.0","openxmlformats.org\u002Fdrawingml\u002F…",[581,671],{"x":611,"y":659,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,673,674],{"x":614,"y":668,"style":632},"purl.oclc.org\u002Fooxml\u002Fdrawingml",[581,676],{"x":589,"y":677,"width":591,"height":619,"rx":374,"fill":620,"stroke":593,"style":594},"158.0",[603,679,681],{"x":623,"y":680,"style":625},"180.0","workbook flag",[581,683],{"x":597,"y":677,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,685,687],{"x":605,"y":686,"style":632},"179.0","—",[581,689],{"x":611,"y":677,"width":598,"height":619,"rx":374,"fill":586,"stroke":593,"style":594},[603,691,543],{"x":614,"y":686,"style":632},[53,693,695],{"id":694},"step-3-convert-the-namespaces-in-memory-and-read-with-pandas","Step 3 — Convert the namespaces in memory and read with pandas",[10,697,698],{},"For ordinary data workbooks the difference is mostly the namespace URIs, including those inside relationship types. Rewrite them back to the transitional ones in an in-memory copy and hand that to pandas:",[58,700,702],{"className":112,"code":701,"language":114,"meta":63,"style":63},"from io import BytesIO\n\nTO_TRANSITIONAL = {\n    \"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002Fspreadsheetml\u002Fmain\": \"http:\u002F\u002Fschemas.openxmlformats.org\u002Fspreadsheetml\u002F2006\u002Fmain\",\n    \"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002FofficeDocument\u002Frelationships\": \"http:\u002F\u002Fschemas.openxmlformats.org\u002FofficeDocument\u002F2006\u002Frelationships\",\n    \"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002Fdrawingml\u002Fmain\": \"http:\u002F\u002Fschemas.openxmlformats.org\u002Fdrawingml\u002F2006\u002Fmain\",\n}\n\ndef strict_to_transitional(path):\n    out = BytesIO()\n    with zipfile.ZipFile(path) as zin, zipfile.ZipFile(out, \"w\", zipfile.ZIP_DEFLATED) as zout:\n        for item in zin.infolist():\n            data = zin.read(item.filename)\n            if item.filename.endswith((\".xml\", \".rels\")):\n                text = data.decode(\"utf-8\")\n                for strict, transitional in TO_TRANSITIONAL.items():\n                    text = text.replace(strict, transitional)\n                data = text.replace(' conformance=\"strict\"', \"\").encode(\"utf-8\")\n            zout.writestr(item, data)\n    out.seek(0)\n    return out\n\ndef read_any_xlsx(path, **kwargs):\n    source = strict_to_transitional(path) if is_strict(path) else path\n    return pd.read_excel(source, **kwargs)\n\nprint(read_any_xlsx(\"sales_strict.xlsx\", sheet_name=\"Sales\").to_string(index=False))\n",[19,703,704,716,720,731,744,756,768,773,777,786,796,823,836,846,865,880,897,908,934,940,950,958,963,980,1001,1014,1019],{"__ignoreMap":63},[67,705,706,708,711,713],{"class":69,"line":70},[67,707,146],{"class":121},[67,709,710],{"class":125}," io ",[67,712,122],{"class":121},[67,714,715],{"class":125}," BytesIO\n",[67,717,718],{"class":69,"line":129},[67,719,161],{"emptyLinePlaceholder":160},[67,721,722,725,728],{"class":69,"line":143},[67,723,724],{"class":227},"TO_TRANSITIONAL",[67,726,727],{"class":121}," =",[67,729,730],{"class":125}," {\n",[67,732,733,736,738,741],{"class":69,"line":157},[67,734,735],{"class":77},"    \"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002Fspreadsheetml\u002Fmain\"",[67,737,278],{"class":125},[67,739,740],{"class":77},"\"http:\u002F\u002Fschemas.openxmlformats.org\u002Fspreadsheetml\u002F2006\u002Fmain\"",[67,742,743],{"class":125},",\n",[67,745,746,749,751,754],{"class":69,"line":164},[67,747,748],{"class":77},"    \"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002FofficeDocument\u002Frelationships\"",[67,750,278],{"class":125},[67,752,753],{"class":77},"\"http:\u002F\u002Fschemas.openxmlformats.org\u002FofficeDocument\u002F2006\u002Frelationships\"",[67,755,743],{"class":125},[67,757,758,761,763,766],{"class":69,"line":191},[67,759,760],{"class":77},"    \"http:\u002F\u002Fpurl.oclc.org\u002Fooxml\u002Fdrawingml\u002Fmain\"",[67,762,278],{"class":125},[67,764,765],{"class":77},"\"http:\u002F\u002Fschemas.openxmlformats.org\u002Fdrawingml\u002F2006\u002Fmain\"",[67,767,743],{"class":125},[67,769,770],{"class":69,"line":200},[67,771,772],{"class":125},"}\n",[67,774,775],{"class":69,"line":221},[67,776,161],{"emptyLinePlaceholder":160},[67,778,779,781,784],{"class":69,"line":237},[67,780,434],{"class":121},[67,782,783],{"class":437}," strict_to_transitional",[67,785,441],{"class":125},[67,787,788,791,793],{"class":69,"line":293},[67,789,790],{"class":125},"    out ",[67,792,215],{"class":121},[67,794,795],{"class":125}," BytesIO()\n",[67,797,798,800,802,804,807,810,813,816,818,820],{"class":69,"line":298},[67,799,446],{"class":121},[67,801,449],{"class":125},[67,803,137],{"class":121},[67,805,806],{"class":125}," zin, zipfile.ZipFile(out, ",[67,808,809],{"class":77},"\"w\"",[67,811,812],{"class":125},", zipfile.",[67,814,815],{"class":227},"ZIP_DEFLATED",[67,817,315],{"class":125},[67,819,137],{"class":121},[67,821,822],{"class":125}," zout:\n",[67,824,825,828,831,833],{"class":69,"line":323},[67,826,827],{"class":121},"        for",[67,829,830],{"class":125}," item ",[67,832,173],{"class":121},[67,834,835],{"class":125}," zin.infolist():\n",[67,837,838,841,843],{"class":69,"line":334},[67,839,840],{"class":125},"            data ",[67,842,215],{"class":121},[67,844,845],{"class":125}," zin.read(item.filename)\n",[67,847,848,851,854,857,859,862],{"class":69,"line":349},[67,849,850],{"class":121},"            if",[67,852,853],{"class":125}," item.filename.endswith((",[67,855,856],{"class":77},"\".xml\"",[67,858,182],{"class":125},[67,860,861],{"class":77},"\".rels\"",[67,863,864],{"class":125},")):\n",[67,866,868,871,873,876,878],{"class":69,"line":867},15,[67,869,870],{"class":125},"                text ",[67,872,215],{"class":121},[67,874,875],{"class":125}," data.decode(",[67,877,473],{"class":77},[67,879,290],{"class":125},[67,881,883,886,889,891,894],{"class":69,"line":882},16,[67,884,885],{"class":121},"                for",[67,887,888],{"class":125}," strict, transitional ",[67,890,173],{"class":121},[67,892,893],{"class":227}," TO_TRANSITIONAL",[67,895,896],{"class":125},".items():\n",[67,898,900,903,905],{"class":69,"line":899},17,[67,901,902],{"class":125},"                    text ",[67,904,215],{"class":121},[67,906,907],{"class":125}," text.replace(strict, transitional)\n",[67,909,911,914,916,919,922,924,927,930,932],{"class":69,"line":910},18,[67,912,913],{"class":125},"                data ",[67,915,215],{"class":121},[67,917,918],{"class":125}," text.replace(",[67,920,921],{"class":77},"' conformance=\"strict\"'",[67,923,182],{"class":125},[67,925,926],{"class":77},"\"\"",[67,928,929],{"class":125},").encode(",[67,931,473],{"class":77},[67,933,290],{"class":125},[67,935,937],{"class":69,"line":936},19,[67,938,939],{"class":125},"            zout.writestr(item, data)\n",[67,941,943,946,948],{"class":69,"line":942},20,[67,944,945],{"class":125},"    out.seek(",[67,947,374],{"class":227},[67,949,290],{"class":125},[67,951,953,955],{"class":69,"line":952},21,[67,954,485],{"class":121},[67,956,957],{"class":125}," out\n",[67,959,961],{"class":69,"line":960},22,[67,962,161],{"emptyLinePlaceholder":160},[67,964,966,968,971,974,977],{"class":69,"line":965},23,[67,967,434],{"class":121},[67,969,970],{"class":437}," read_any_xlsx",[67,972,973],{"class":125},"(path, ",[67,975,976],{"class":121},"**",[67,978,979],{"class":125},"kwargs):\n",[67,981,983,986,988,991,993,996,998],{"class":69,"line":982},24,[67,984,985],{"class":125},"    source ",[67,987,215],{"class":121},[67,989,990],{"class":125}," strict_to_transitional(path) ",[67,992,386],{"class":121},[67,994,995],{"class":125}," is_strict(path) ",[67,997,392],{"class":121},[67,999,1000],{"class":125}," path\n",[67,1002,1004,1006,1009,1011],{"class":69,"line":1003},25,[67,1005,485],{"class":121},[67,1007,1008],{"class":125}," pd.read_excel(source, ",[67,1010,976],{"class":121},[67,1012,1013],{"class":125},"kwargs)\n",[67,1015,1017],{"class":69,"line":1016},26,[67,1018,161],{"emptyLinePlaceholder":160},[67,1020,1022,1024,1027,1029,1031,1034,1036,1039,1042,1045,1047,1050],{"class":69,"line":1021},27,[67,1023,352],{"class":227},[67,1025,1026],{"class":125},"(read_any_xlsx(",[67,1028,206],{"class":77},[67,1030,182],{"class":125},[67,1032,1033],{"class":211},"sheet_name",[67,1035,215],{"class":121},[67,1037,1038],{"class":77},"\"Sales\"",[67,1040,1041],{"class":125},").to_string(",[67,1043,1044],{"class":211},"index",[67,1046,215],{"class":121},[67,1048,1049],{"class":227},"False",[67,1051,537],{"class":125},[10,1053,1054,1055,1057,1058,1061,1062,1065,1066,182,1069,1072,1073,1076],{},"The rewritten copy reads normally — the ",[14,1056,104],{}," sheet with all three regions — and the original file is untouched. Because the copy lives in a ",[19,1059,1060],{},"BytesIO"," buffer, nothing is written to disk, which matters when the input folder is read-only or shared, and the conversion costs about as much as reading the file twice. Because the relationship ",[14,1063,1064],{},"types"," are URIs under the same namespace prefix (",[19,1067,1068],{},"…\u002Frelationships\u002Fworksheet",[19,1070,1071],{},"…\u002Frelationships\u002FofficeDocument","), replacing the prefix fixes them too. ",[19,1074,1075],{},"read_any_xlsx"," makes the check-and-convert step invisible to the rest of a pipeline. The limits are worth stating: Strict also allows dates to be stored as ISO strings and has a few other structural differences, and workbooks with charts, pivot tables or other rich content use more namespaces than these three. For plain data sheets the rewrite is enough; for anything richer, or if the result looks wrong, use LibreOffice.",[562,1078,571,1083,571,1086,571,1089,571,1092,571,1098,571,1109,571,1115,571,1119,571,1122,571,1127,571,1132,571,1137,571,1144,571,1150,571,1154,571,1158,571,1161,571,1166,571,1173,571,1177,571,1180,571,1183,571,1187,571,1190,571,1193,571,1200,571,1205],{"viewBox":1079,"role":565,"ariaLabelledBy":1080,"xmlns":569,"style":570},"4 0 752 142",[1081,1082],"sx-read-t","sx-read-d",[573,1084,1085],{"id":1081},"Reading a workbook that might be Strict",[577,1087,1088],{"id":1082},"Check the workbook part for the strict conformance flag or purl.oclc.org namespaces. If it is transitional, read it directly. If it is Strict, rewrite the namespaces in an in-memory copy and read that with pandas, or convert it with LibreOffice when the workbook has rich content.",[581,1090],{"x":583,"y":374,"width":584,"height":1091,"fill":586},"142",[581,1093],{"x":589,"y":590,"width":1094,"height":1095,"rx":1096,"fill":620,"stroke":593,"style":1097},"153.0","110.5","12","stroke-width:2px",[1099,1100,1102],"g",{"transform":1101},"translate(84.5,29.0) scale(1.000)",[1103,1104],"path",{"d":1105,"fill":1106,"stroke":1107,"style":1108},"M11 4a7 7 0 1 0 .01 0z M16 16l5 5","none","var(--text,#172033)","stroke-width:1.80px;stroke-linecap:round;stroke-linejoin:round",[603,1110,1114],{"x":1111,"y":1112,"style":1113},"96.5","75.5","font-size:13.5px;font-weight:700;fill:var(--text,#172033);text-anchor:middle","is_strict()",[603,1116,1118],{"x":1111,"y":1117,"style":632},"95.0","check",[603,1120,555],{"x":1111,"y":1121,"style":632},"112.5",[69,1123],{"x1":1124,"y1":1125,"x2":1126,"y2":1125,"stroke":600,"style":1097},"178.0","71.2","200.0",[1128,1129],"polygon",{"points":1130,"fill":1131},"204.0,71.2 195.0,76.2 195.0,66.2","#5b5cf0",[581,1133],{"x":1134,"y":590,"width":1094,"height":1095,"rx":1096,"fill":1135,"stroke":1136,"style":1097},"209.0","#d9f4f1","var(--teal,#0f9488)",[1099,1138,1140],{"transform":1139},"translate(273.5,37.8) scale(1.000)",[1103,1141],{"d":1142,"fill":1106,"stroke":1143,"style":1108},"M3 5h18v14H3z M3 10h18 M3 15h18 M9 5v14","var(--teal-ink,#0b6157)",[603,1145,1149],{"x":1146,"y":1147,"style":1148},"285.5","84.2","font-size:13.5px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","Transitional",[603,1151,1153],{"x":1146,"y":1152,"style":632},"103.8","read directly",[69,1155],{"x1":1156,"y1":1125,"x2":1157,"y2":1125,"stroke":600,"style":1097},"367.0","389.0",[1128,1159],{"points":1160,"fill":1131},"393.0,71.2 384.0,76.2 384.0,66.2",[581,1162],{"x":1163,"y":590,"width":1094,"height":1095,"rx":1096,"fill":1164,"stroke":1165,"style":1097},"398.0","#fdefd8","var(--gold,#b4740a)",[1099,1167,1169],{"transform":1168},"translate(462.5,29.0) scale(1.000)",[1103,1170],{"d":1171,"fill":1106,"stroke":1172,"style":1108},"M20 11a8 8 0 1 0-2.3 5.7 M20 4v7h-7","var(--gold-ink,#7a4e06)",[603,1174,44],{"x":1175,"y":1112,"style":1176},"474.5","font-size:13.5px;font-weight:700;fill:var(--gold-ink,#7a4e06);text-anchor:middle",[603,1178,1179],{"x":1175,"y":1117,"style":632},"rewrite namespaces in",[603,1181,1182],{"x":1175,"y":1121,"style":632},"memory",[69,1184],{"x1":1185,"y1":1125,"x2":1186,"y2":1125,"stroke":600,"style":1097},"556.0","578.0",[1128,1188],{"points":1189,"fill":1131},"582.0,71.2 573.0,76.2 573.0,66.2",[581,1191],{"x":1192,"y":590,"width":1094,"height":1095,"rx":1096,"fill":599,"stroke":600,"style":1097},"587.0",[1099,1194,1196],{"transform":1195},"translate(651.5,37.8) scale(1.000)",[1103,1197],{"d":1198,"fill":1106,"stroke":1199,"style":1108},"M12 9a3 3 0 1 0 .01 0z M12 2.5v3 M12 18.5v3 M2.5 12h3 M18.5 12h3 M5.3 5.3l2.1 2.1 M16.6 16.6l2.1 2.1 M5.3 18.7l2.1-2.1 M16.6 7.4l2.1-2.1","var(--brand-strong,#4338ca)",[603,1201,1204],{"x":1202,"y":1147,"style":1203},"663.5","font-size:13.5px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","Rich content",[603,1206,1207],{"x":1202,"y":1152,"style":632},"LibreOffice conversion",[53,1209,1211],{"id":1210},"step-4-convert-with-libreoffice-when-the-rewrite-is-not-enough","Step 4 — Convert with LibreOffice when the rewrite is not enough",[10,1213,1214],{},"LibreOffice reads Strict files fully and can write them back out as ordinary workbooks:",[58,1216,1218],{"className":112,"code":1217,"language":114,"meta":63,"style":63},"import subprocess\n\nsubprocess.run([\"soffice\", \"--headless\", \"--convert-to\", \"xlsx:Calc MS Excel 2007 XML\", \"--outdir\", \"converted\", \"sales_strict.xlsx\"],\n               check=True, capture_output=True)\nconverted = \"converted\u002Fsales_strict.xlsx\"\nprint(\"strict after conversion:\", is_strict(converted))\nprint(pd.read_excel(converted).to_string(index=False))\n",[19,1219,1220,1227,1231,1271,1291,1301,1313],{"__ignoreMap":63},[67,1221,1222,1224],{"class":69,"line":70},[67,1223,122],{"class":121},[67,1225,1226],{"class":125}," subprocess\n",[67,1228,1229],{"class":69,"line":129},[67,1230,161],{"emptyLinePlaceholder":160},[67,1232,1233,1236,1239,1241,1244,1246,1249,1251,1254,1256,1259,1261,1264,1266,1268],{"class":69,"line":143},[67,1234,1235],{"class":125},"subprocess.run([",[67,1237,1238],{"class":77},"\"soffice\"",[67,1240,182],{"class":125},[67,1242,1243],{"class":77},"\"--headless\"",[67,1245,182],{"class":125},[67,1247,1248],{"class":77},"\"--convert-to\"",[67,1250,182],{"class":125},[67,1252,1253],{"class":77},"\"xlsx:Calc MS Excel 2007 XML\"",[67,1255,182],{"class":125},[67,1257,1258],{"class":77},"\"--outdir\"",[67,1260,182],{"class":125},[67,1262,1263],{"class":77},"\"converted\"",[67,1265,182],{"class":125},[67,1267,206],{"class":77},[67,1269,1270],{"class":125},"],\n",[67,1272,1273,1276,1278,1280,1282,1285,1287,1289],{"class":69,"line":157},[67,1274,1275],{"class":211},"               check",[67,1277,215],{"class":121},[67,1279,312],{"class":227},[67,1281,182],{"class":125},[67,1283,1284],{"class":211},"capture_output",[67,1286,215],{"class":121},[67,1288,312],{"class":227},[67,1290,290],{"class":125},[67,1292,1293,1296,1298],{"class":69,"line":164},[67,1294,1295],{"class":125},"converted ",[67,1297,215],{"class":121},[67,1299,1300],{"class":77}," \"converted\u002Fsales_strict.xlsx\"\n",[67,1302,1303,1305,1307,1310],{"class":69,"line":191},[67,1304,352],{"class":227},[67,1306,243],{"class":125},[67,1308,1309],{"class":77},"\"strict after conversion:\"",[67,1311,1312],{"class":125},", is_strict(converted))\n",[67,1314,1315,1317,1320,1322,1324,1326],{"class":69,"line":200},[67,1316,352],{"class":227},[67,1318,1319],{"class":125},"(pd.read_excel(converted).to_string(",[67,1321,1044],{"class":211},[67,1323,215],{"class":121},[67,1325,1049],{"class":227},[67,1327,537],{"class":125},[10,1329,1330,1331,1334,1335,1339],{},"The ",[19,1332,1333],{},"Calc MS Excel 2007 XML"," export filter writes the ordinary transitional format, which every Python library reads; the converted file is no longer Strict and gives the same data. LibreOffice handles the content the namespace rewrite does not — ISO dates, charts, styles — at the cost of needing LibreOffice installed and taking a second or two per file. It is the right choice for batch conversion of an archive of Strict workbooks. Conversions in general are covered in ",[47,1336,1338],{"href":1337},"\u002Fautomating-reporting-workflows\u002Fexporting-excel-reports-to-pdf\u002Fconvert-excel-to-pdf-on-linux-with-libreoffice\u002F","Convert Excel to PDF on Linux with LibreOffice",", which uses the same command with a different target.",[562,1341,571,1346,571,1349,571,1352,571,1355,571,1359,571,1365,571,1369,571,1373,571,1377,571,1380,571,1383,571,1389,571,1394,571,1399,571,1404,571,1408,571,1412,571,1414,571,1417,571,1421,571,1424,571,1427,571,1432,571,1434,571,1437,571,1439,571,1442,571,1446,571,1449,571,1452,571,1458,571,1461],{"viewBox":1342,"role":565,"ariaLabelledBy":1343,"xmlns":569,"style":570},"4 0 752 272",[1344,1345],"sx-choose-t","sx-choose-d",[573,1347,1348],{"id":1344},"Namespace rewrite or LibreOffice?",[577,1350,1351],{"id":1345},"For a plain data workbook read by a Python job, rewrite the namespaces in memory, which is fast and needs nothing installed. For workbooks with charts, pivot tables or dates stored as text, or for archives of many files to convert once, use LibreOffice.",[581,1353],{"x":583,"y":374,"width":584,"height":1354,"fill":586},"272",[581,1356],{"x":1357,"y":590,"width":1358,"height":1112,"rx":1096,"fill":599,"stroke":600,"style":1097},"240.0","280.0",[1099,1360,1362],{"transform":1361},"translate(368.0,29.0) scale(1.000)",[1103,1363],{"d":1364,"fill":1106,"stroke":1199,"style":1108},"M6 3h9l4 4v14H6z M15 3v4h4 M9.5 11.5l4.5 6 M14 11.5l-4.5 6",[603,1366,1368],{"x":1367,"y":1112,"style":1203},"380.0","What is in the Strict workbook?",[69,1370],{"x1":1367,"y1":1371,"x2":1367,"y2":1372,"stroke":600,"style":1097},"91.5","111.5",[69,1374],{"x1":1375,"y1":1372,"x2":1376,"y2":1372,"stroke":600,"style":1097},"134.7","625.3",[69,1378],{"x1":1375,"y1":1372,"x2":1375,"y2":1379,"stroke":600,"style":1097},"157.5",[1128,1381],{"points":1382,"fill":1131},"134.7,161.5 129.7,152.5 139.7,152.5",[581,1384],{"x":1112,"y":1385,"width":1386,"height":1387,"rx":1388,"fill":586,"stroke":593,"style":601},"121.5","118.3","21.0","10",[603,1390,1393],{"x":1375,"y":1391,"style":1392},"136.0","font-size:11.5px;font-weight:700;fill:var(--muted,#5b6780);text-anchor:middle","plain data sheets",[581,1395],{"x":589,"y":1396,"width":1397,"height":1398,"rx":1096,"fill":1135,"stroke":1136,"style":1097},"163.5","229.3","93.0",[1099,1400,1402],{"transform":1401},"translate(122.7,176.5) scale(1.000)",[1103,1403],{"d":1171,"fill":1106,"stroke":1143,"style":1108},[603,1405,1407],{"x":1375,"y":1406,"style":1148},"223.0","in-memory rewrite",[603,1409,1411],{"x":1375,"y":1410,"style":632},"242.5","fast, no extra software",[69,1413],{"x1":1367,"y1":1372,"x2":1367,"y2":1379,"stroke":600,"style":1097},[1128,1415],{"points":1416,"fill":1131},"380.0,161.5 375.0,152.5 385.0,152.5",[581,1418],{"x":1419,"y":1385,"width":1420,"height":1387,"rx":1388,"fill":586,"stroke":593,"style":601},"298.6","162.7",[603,1422,1423],{"x":1367,"y":1391,"style":1392},"charts, pivots, ISO dates",[581,1425],{"x":1426,"y":1396,"width":1397,"height":1398,"rx":1096,"fill":599,"stroke":600,"style":1097},"265.3",[1099,1428,1430],{"transform":1429},"translate(368.0,176.5) scale(1.000)",[1103,1431],{"d":1198,"fill":1106,"stroke":1199,"style":1108},[603,1433,1207],{"x":1367,"y":1406,"style":1203},[603,1435,1436],{"x":1367,"y":1410,"style":632},"complete and reliable",[69,1438],{"x1":1376,"y1":1372,"x2":1376,"y2":1379,"stroke":600,"style":1097},[1128,1440],{"points":1441,"fill":1131},"625.3,161.5 620.3,152.5 630.3,152.5",[581,1443],{"x":1444,"y":1385,"width":1445,"height":1387,"rx":1388,"fill":586,"stroke":593,"style":601},"563.9","122.9",[603,1447,1448],{"x":1376,"y":1391,"style":1392},"an archive of files",[581,1450],{"x":1451,"y":1396,"width":1397,"height":1398,"rx":1096,"fill":1164,"stroke":1165,"style":1097},"510.7",[1099,1453,1455],{"transform":1454},"translate(613.3,176.5) scale(1.000)",[1103,1456],{"d":1457,"fill":1106,"stroke":1172,"style":1108},"M3 6h6l2 2h10v11H3z",[603,1459,1460],{"x":1376,"y":1406,"style":1176},"batch with LibreOffice",[603,1462,1463],{"x":1376,"y":1410,"style":632},"convert once, keep originals",[53,1465,1467],{"id":1466},"finding-strict-files-in-a-folder","Finding Strict files in a folder",[10,1469,1470,1471,1474,1475,1477,1478,1481,1482,1484],{},"When files arrive from many senders, scan the incoming folder with the same check and report Strict workbooks alongside the data job's other warnings. A loop over ",[19,1472,1473],{},"Path(\"inbox\").glob(\"*.xlsx\")"," that calls ",[19,1476,1114],{}," on each file, skipping Excel's ",[19,1479,1480],{},"~$"," lock files, lists the senders to contact; the check reads one small part of each archive, so it is quick even for large workbooks. Logging \"converted from Strict Open XML\" whenever ",[19,1483,1075],{}," takes the conversion path also leaves a trace, so if a converted file's figures are ever questioned, the conversion is the first thing to rule out — compare with a LibreOffice conversion of the same file, which should give identical values for plain data sheets, as it did here.",[53,1486,1488],{"id":1487},"stop-them-arriving","Stop them arriving",[10,1490,1491,1492,1495,1496,1499,1500,1503],{},"Strict files usually come from one person or one system set to save in that format. In Excel, ",[14,1493,1494],{},"File › Save As"," shows the format in the type list: choosing ",[14,1497,1498],{},"Excel Workbook (*.xlsx)"," instead fixes it for that file, and ",[14,1501,1502],{},"File › Options › Save › Save files in this format"," sets the default. A system that exports Strict workbooks may have a setting for the ordinary format. Telling the sender — with the check from Step 2 in your job's error message — is usually the quickest permanent fix.",[53,1505,1507],{"id":1506},"common-pitfalls","Common pitfalls",[1509,1510,1511,1519,1525,1531,1537],"ul",{},[1512,1513,1514,1518],"li",{},[1515,1516,1517],"strong",{},"Assuming the file is corrupt."," It opens in Excel; check for Strict first.",[1512,1520,1521,1524],{},[1515,1522,1523],{},"Confusing the two \"0 worksheets\" causes."," Strict namespaces and broken relationship paths need different fixes.",[1512,1526,1527,1530],{},[1515,1528,1529],{},"Rewriting rich workbooks."," The namespace swap suits plain data; use LibreOffice for charts and pivots.",[1512,1532,1533,1536],{},[1515,1534,1535],{},"Overwriting the original."," Convert in memory or into a separate folder.",[1512,1538,1539,1542,1543,51],{},[1515,1540,1541],{},"Fixing every file forever."," Ask the sender to save as ",[14,1544,25],{},[53,1546,1548],{"id":1547},"conclusion","Conclusion",[10,1550,1551,1552,1555,1556,1558,1559,1561,1562,1564,1565,1567],{},"A Strict Open XML workbook uses ",[19,1553,1554],{},"purl.oclc.org\u002Fooxml"," namespaces and a ",[19,1557,543],{}," flag, which makes openpyxl find no worksheets and calamine fail to detect the format. Detect it by reading ",[19,1560,555],{},", then either rewrite the namespaces to the transitional ones in an in-memory copy and read that with pandas, or convert the file with LibreOffice's ",[19,1563,1333],{}," filter when it contains more than plain data — and ask the sender to save as ",[14,1566,25],{}," in future.",[53,1569,1571],{"id":1570},"frequently-asked-questions","Frequently asked questions",[10,1573,1574,1577],{},[1515,1575,1576],{},"What is a Strict Open XML Excel file?","\nAn .xlsx saved with Excel's Strict Open XML Spreadsheet option; it uses the strict variant of the ISO standard, with different XML namespaces from the usual Excel Workbook format.",[10,1579,1580,1583],{},[1515,1581,1582],{},"Why does pandas say \"Worksheet index 0 is invalid, 0 worksheets found\" for my file?","\nOne common cause is a Strict Open XML workbook: openpyxl does not recognise its namespaces and finds no sheets. Check xl\u002Fworkbook.xml for purl.oclc.org namespaces.",[10,1585,1586,1589],{},[1515,1587,1588],{},"How do I read a Strict xlsx file with pandas?","\nRewrite the purl.oclc.org namespaces to the transitional schemas.openxmlformats.org ones in an in-memory copy and read that, or convert the file with LibreOffice first.",[10,1591,1592,1595],{},[1515,1593,1594],{},"How do I stop Excel saving files as Strict Open XML?","\nUse Save As and choose Excel Workbook (*.xlsx), and set the default format under File › Options › Save.",[53,1597,1599],{"id":1598},"related","Related",[1509,1601,1602,1608,1613,1620],{},[1512,1603,1604,1605,1607],{},"Up one level: ",[47,1606,50],{"href":49}," — converting between formats.",[1512,1609,1610,1612],{},[47,1611,408],{"href":407}," — the other cause of the same error.",[1512,1614,1615,1619],{},[47,1616,1618],{"href":1617},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-excel-file-format-cannot-be-determined-in-pandas\u002F","Fix \"Excel file format cannot be determined\" in pandas"," — when pandas cannot tell what a file is.",[1512,1621,1622,1626],{},[47,1623,1625],{"href":1624},"\u002Fgetting-started-with-python-excel-automation\u002Ftroubleshooting-common-python-excel-errors\u002Ffix-badzipfile-error-when-reading-excel-in-python\u002F","Fix BadZipFile Error When Reading Excel in Python"," — when the file is not a zip at all.",[1628,1629,1630],"style",{},"html pre.shiki code .sMTad, html code.shiki .sMTad{--shiki-default:#6F42C1;--shiki-dark:#FFB757}html pre.shiki code .srMev, html code.shiki .srMev{--shiki-default:#032F62;--shiki-dark:#ADDCFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s-kum, html code.shiki .s-kum{--shiki-default:#D73A49;--shiki-dark:#FF9492}html pre.shiki code .skGVy, html code.shiki .skGVy{--shiki-default:#24292E;--shiki-dark:#F0F3F6}html pre.shiki code .sa561, html code.shiki .sa561{--shiki-default:#E36209;--shiki-dark:#FFB757}html pre.shiki code .sP0c6, html code.shiki .sP0c6{--shiki-default:#005CC5;--shiki-dark:#91CBFF}html pre.shiki code .sSjpA, html code.shiki .sSjpA{--shiki-default:#005CC5;--shiki-dark:#FF9492}html pre.shiki code .s_Opv, html code.shiki .s_Opv{--shiki-default:#6F42C1;--shiki-dark:#DBB7FF}",{"title":63,"searchDepth":129,"depth":129,"links":1632},[1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643],{"id":55,"depth":129,"text":56},{"id":108,"depth":129,"text":109},{"id":412,"depth":129,"text":413},{"id":694,"depth":129,"text":695},{"id":1210,"depth":129,"text":1211},{"id":1466,"depth":129,"text":1467},{"id":1487,"depth":129,"text":1488},{"id":1506,"depth":129,"text":1507},{"id":1547,"depth":129,"text":1548},{"id":1570,"depth":129,"text":1571},{"id":1598,"depth":129,"text":1599},"2026-10-02","Read workbooks saved in Excel's \"Strict Open XML Spreadsheet\" format, which pandas, openpyxl and calamine reject with \"Worksheet index 0 is invalid, 0 worksheets found\" or \"Cannot detect file format\": recognise a Strict file, convert its namespaces to the usual transitional ones in memory so pandas can read it, convert with LibreOffice when that is not enough, and stop the files arriving.","md",[1648,1650,1652,1654],{"q":1576,"a":1649},"An .xlsx saved with Excel's Strict Open XML Spreadsheet option; it uses the strict variant of the ISO standard, with different XML namespaces from the usual Excel Workbook format.",{"q":1582,"a":1651},"One common cause is a Strict Open XML workbook: openpyxl does not recognise its namespaces and finds no sheets. Check xl\u002Fworkbook.xml for purl.oclc.org namespaces.",{"q":1588,"a":1653},"Rewrite the purl.oclc.org namespaces to the transitional schemas.openxmlformats.org ones in an in-memory copy and read that, or convert the file with LibreOffice first.",{"q":1594,"a":1655},"Use Save As and choose Excel Workbook (*.xlsx), and set the default format under File › Options › Save.","read strict open xml excel files python",null,{"breadcrumb":1659},[1660,1663,1666],{"name":1661,"item":1662},"Home","\u002F",{"name":1664,"item":1665},"Getting Started with Python Excel Automation","\u002Fgetting-started-with-python-excel-automation\u002F",{"name":50,"item":49},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python",{"title":5,"description":1669},"Strict OOXML .xlsx files in Python: why openpyxl finds 0 worksheets and calamine cannot detect the format, detecting purl.oclc.org namespaces, an in-memory namespace rewrite for pandas, LibreOffice conversion and prevention.","read-strict-open-xml-excel-files-in-python","getting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-strict-open-xml-excel-files-in-python\u002Findex",[1673,1674],"file-formats","troubleshooting","how-to","E05WeVtYtLOZ_uHcFKhHv0vrgI_M2CteSGf7T2NwYm0",[1678,1682],{"title":1679,"path":1680,"stem":1681,"children":-1},"Read Excel 2003 XML Spreadsheet Files","\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-excel-2003-xml-spreadsheet-files","getting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-excel-2003-xml-spreadsheet-files\u002Findex",{"title":1683,"path":1684,"stem":1685,"children":-1},"Read .xls Files in Python with xlrd and pandas","\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-xls-files-in-python-with-xlrd-and-pandas","getting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions\u002Fread-xls-files-in-python-with-xlrd-and-pandas\u002Findex",[1687,1689],{"path":1688,"title":50},"\u002Fgetting-started-with-python-excel-automation\u002Fhandling-excel-file-formats-and-conversions",{"path":1690,"title":1664},"\u002Fgetting-started-with-python-excel-automation",[],[1693,1696,1699,1703,1706,1710],{"path":1694,"title":1695,"kind":1675},"\u002Fadvanced-data-transformation-and-cleaning\u002Freading-excel-with-polars-and-arrow\u002Fconvert-excel-files-to-parquet-with-python","Convert Excel Files to Parquet with Python",{"path":1697,"title":1698,"kind":1675},"\u002Fadvanced-data-transformation-and-cleaning\u002Fworking-with-large-excel-files-in-python\u002Fconvert-excel-to-csv-with-python","Convert Excel to CSV with Python",{"path":1700,"title":1701,"kind":1702},"\u002Fgetting-started-with-python-excel-automation\u002Fchoosing-a-python-excel-library\u002Fexcel-vs-csv-vs-parquet-for-python-data-pipelines","Excel vs CSV vs Parquet for Python Data Pipelines","compare",{"path":1704,"title":1705,"kind":1702},"\u002Fgetting-started-with-python-excel-automation\u002Fchoosing-a-python-excel-library\u002Fpick-an-excel-engine-for-xlsx-xlsm-xls-xlsb-and-ods","Pick an Excel Engine for .xlsx, .xlsm, .xls, .xlsb and .ods",{"path":1707,"title":1708,"kind":1709},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Ffix-garbled-characters-in-excel-data","Fix Garbled Characters Like \"CafÃ©\" and \"â€™\" in Excel Data","fix",{"path":1711,"title":1712,"kind":1675},"\u002Fgetting-started-with-python-excel-automation\u002Fautomating-excel-with-com-and-pywin32\u002Fextract-vba-macro-code-from-an-excel-file","Extract VBA Macro Code from an Excel File",1790972064845]