Python Forum
Worksheets doesn't get processed when files to be processed are more than 1
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Worksheets doesn't get processed when files to be processed are more than 1
#1
Sad My issue is when ever I copy worksheets from 1 file to another it works, but not from 1 file to multiple files. To elaborate further, if files to be copied are more than 1, copy doesn't work stuck on 1st file, but if listing are reversed last file in list get's copied information. Here is the section of code that gives me problem
str = ''.join(match)
	for root, dirs, files in os.walk(os.path.abspath(str)):
		for file in reversed(files):
			jobno_files_found = os.path.join(root, file)
			print("files found: ", jobno_files_found)			
			wb2 = openpyxl.load_workbook(jobno_files_found)
			print("wb2.sheetnames: ", wb2.sheetnames)
			for jobno_found in wb2.sheetnames:
				print("jobno_found: ", jobno_found)
				temp_sheet = template[jobno_found] #Add Sheet name
				createData(sheet,temp_sheet,template,jobno_files_found,original_source_wb_row_no)
The code runs showing all sheets per file when last 2 lines are removed, but when lines are included sheet not found error is coming from code below, which doesn't makes sense since sheets are seen above.
temp_sheet = template[jobno_found] #Add Sheet name
Any help or advice is greatly appreciated, thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  output provide the filename along with the input file processed. arjunaram 1 953 Apr-13-2023, 08:15 PM
Last Post: menator01
  How to delete portion of file already processed? Mark17 13 2,784 Jan-22-2022, 09:24 AM
Last Post: Pedroski55
  Merging excel worksheets with balnk rows sauravksingh85 1 1,338 May-19-2020, 12:46 PM
Last Post: sauravksingh85
  Python Script Spawned by Cron or Systemd doesn't write files..? johnnyrobot 2 2,606 May-24-2019, 07:04 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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