Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.list dir not working
#1
Hello,

For some reason this isn't working, it shows files list as 0 []. I have 6 .xlsx files in the input_dir. If I put the .xlsx file where the script is it will work, but I need these .xlsx files in their own folder not with the script.

import openpyxl as xl 
import os
import pandas as pd
import xlsxwriter

input_dir = 'C:\\Users\\\work\\comparison'

files = [file for file in os.listdir(input_dir)
         if os.path.isfile(file) and file.endswith(".xlsx")]


for file in files: 
   input_file =  os.path.join(input_dir, file)
   wb1=xl.load_workbook(input_file)
   ws1=wb1.worksheets[0]
Reply


Messages In This Thread
os.list dir not working - by Kristenl2784 - Jul-29-2020, 01:41 PM
RE: os.list dir not working - by Axel_Erfurt - Jul-29-2020, 02:00 PM
RE: os.list dir not working - by Kristenl2784 - Jul-29-2020, 02:14 PM
RE: os.list dir not working - by deanhystad - Jul-29-2020, 02:50 PM
RE: os.list dir not working - by Kristenl2784 - Jul-29-2020, 03:24 PM
RE: os.list dir not working - by Marbelous - Jul-29-2020, 03:59 PM
RE: os.list dir not working - by deanhystad - Jul-29-2020, 04:12 PM
RE: os.list dir not working - by Marbelous - Jul-29-2020, 04:20 PM
RE: os.list dir not working - by deanhystad - Jul-29-2020, 04:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python3: iterating through list not working wardancer84 3 2,382 Jul-08-2020, 04:30 PM
Last Post: DPaul
  Finding MINIMUM number in a random list is not working Mona 5 3,101 Nov-18-2019, 07:27 PM
Last Post: ThomasL
  Appending to list not working and causing a infinite loop eiger23 8 4,038 Oct-10-2019, 03:41 PM
Last Post: eiger23
  list not working Zman350x 2 2,407 Mar-10-2018, 12:21 AM
Last Post: Zman350x

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020