Skip to content
Advertisement

How to generate multiple file paths and save them into a excel with python

I want to generate hundreds of file paths in python and save them into an excel file. Each path should save in a separate row and paths vary just by one value. I am not sure how to iterate it through a for loop.

Here is my try:

JavaScript

Output is excel file should be like below:

JavaScript

Advertisement

Answer

There are a few mistakes here:

  • workbook should be closed outside of the for loop
  • if you want to start generation from 0 but write the first line in row number one in the excel file you should do i+1 in the row count
  • there shouldn’t be a space after a range keyword

The fixed snipped should look like this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement