Home > Net >  how to convert multiple html files to excel xlsx files
how to convert multiple html files to excel xlsx files

Time:11-01

import pandas as pd

a = "/Users/abhijitchavan/Desktop/yes/SearchResult1.xls"
tables = pd.read_html(a)
table = tables[0]

print(table)

table.to_excel('/Users/abhijitchavan/Desktop/yes/dd.xlsx')

THE ABOVE CODE WORKES PERFECT, BUT IT CONVERTS ONLY ONE FILE AT A TIME, HOW CAN I INPUT MULTIPLE FILES AND CONVERT THEM AT SAME TIME

(FILE EXTENSION IS .XLS BUT THOSE FILE ARE HTML FILES)

THE ABOVE CODE WORKES PERFECT, BUT IT CONVERTS ONLY ONE FILE AT A TIME, HOW CAN I INPUT MULTIPLE FILES AND CONVERT THEM AT SAME TIME

(FILE EXTENSION IS .XLS BUT THOSE FILE ARE HTML FILES)

CodePudding user response:

import pandas as pd
files = ["/Users/abhijitchavan/Desktop/yes/SearchResult1.xls","/Users/abhijitchavan/Desktop/yes/SearchResult2.xls"]
for i in range(0,len(files)):
    a=files[i]
    tables = pd.read_html(a)
    table = tables[0]
    print(table)
    table.to_excel('/Users/abhijitchavan/Desktop/yes/dd" str(i) ".xlsx')
  • Related