When I first go into the folder G:\My Drive\Chip data I can retrieve all the names of the excel sheets from that folder. But when I try to use the names of each file using the same directory as before to open each excel sheet I get the error filenotfound. Any help is appreciated!
import os
import glob
import xlwings as xw
import numpy as np
import matplotlib.pyplot as plt
import array
import math
def Excel_Data():
excels = []
app = xw.apps.active
for root, dirs, files in os.walk(r'G:\My Drive\Chip data'):
for file in files:
if file.endswith('.xlsx') and not file.startswith('~'):
file = file[:-5]
excels.append(file)
dir = r'G:\My Drive\Chip data'
for i in excels:
xw.Book(os.path.join(dir, i))
Try like this:
you are opening file with
xw.Book(os.path.join(dir, i))but it's file without 'xlsx' extension.If you are opening it from Google drive not a folder from your computer there may be another issue. Use api instread