Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python loop problem
#11
(Jun-17-2020, 07:49 PM)buran Wrote:
(Jun-17-2020, 07:25 PM)Kristenl2784 Wrote: Will I need to change the name = NNB-6a_v1_T01 Report manually so that it goes through all of the files?
it's in the loop - file variable is exactly that. you need to make transformations and get what you want the new name to be, then use it to create output_file variable used in save()

I'm not sure what you mean by this. Sorry super new to Python.
Reply
#12
(Jun-18-2020, 03:52 PM)Kristenl2784 Wrote: I'm not sure what you mean by this. Sorry super new to Python.
starting from line 12 you have a for loop

for file in files:
you iterate over files and file is a variable that holds each file name as a string. So you can use file and change it as I show you and get new name and save the file. In next iteration of the loop it will hold next file name and so on...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  While Loop Problem Benno2805 1 537 Sep-06-2023, 04:51 PM
Last Post: deanhystad
  Loop reading csv file problem faustineaiden 1 1,539 Dec-11-2021, 08:40 AM
Last Post: ibreeden
  Infinite loop problem Zirconyl 5 2,923 Nov-16-2020, 09:06 AM
Last Post: DeaD_EyE
  Dataframe mean calculation problem: do we have to loop? sparkt 1 2,134 Aug-28-2020, 02:41 PM
Last Post: sparkt
  Problem with append list in loop michaelko03 0 1,638 Feb-16-2020, 07:04 PM
Last Post: michaelko03
  problem with for loop using integers python_germ 5 2,942 Aug-31-2019, 11:42 AM
Last Post: jefsummers
  problem in loop roseojha 3 2,238 Aug-26-2019, 09:03 AM
Last Post: perfringo
  Nested while loop problem + turtle DreamingInsanity 3 2,906 Jul-06-2019, 02:01 PM
Last Post: DreamingInsanity
  Problem Passing Arguement to do loop stephenmolnar 10 4,744 May-13-2019, 02:56 PM
Last Post: Gribouillis
  Nested for loop strange problem mcva 2 2,570 Mar-16-2019, 12:53 PM
Last Post: mcva

Forum Jump:

User Panel Messages

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