0

I've got loads of 97-2003 excel xls files i wanna bulk convert to xlsx - i found this documentation but cant seem to get it to work..

https://pypi.org/project/xls2xlsx/

Have tried googling the errors and searching but no avail.

import os

from xls2xlsx import XLS2XLSX


directory = 'C:\\Users\\Python Scripts\\convertXLStoXLSX\\'


for filename in os.listdir(directory):

    if filename.endswith(".xls"):
        x2x = XLS2XLSX(filename)
        x2x.to_xlsx(filename)
        
    else:
        continue

I am getting the error message

ImportError: cannot import name 'GuessedAtParserWarning' from 'bs4' (C:\Users\wf5931\AppData\Local\Continuum\anaconda3\lib\site-packages\bs4_init_.py)

ASG
  • 21
  • 1
  • 5

2 Answers2

0

use pandas

import pandas as pd
df = pd.read_excel("file.xls")
df.to_excel("file.xlsx")
sepideh_ssh
  • 196
  • 2
  • 8
0

Just including my finished code for future use by others which uses pandas - worked almost instantly

import os import pandas as pd

directory = 'C:\\Users\\Documents\\Python Scripts\\convertXLStoXLSX\\'

for filename in os.listdir(directory):

    if filename.endswith(".xls"):
        df = pd.read_excel(filename)
        df.to_excel(filename + ".xlsx")
ASG
  • 21
  • 1
  • 5