0

I am using Python to process over 100.000 text files which are in a folder:

for f in glob.glob("/folder_path/*.txt"):
 with open(f) as inputfile:

Is there a way to start processing from the N-th file in the folder (let's say from the 30.000 th file in the folder), instead of starting over from the 1st file every time in the folder?

I know I can move the files I don't want to process in another file, but since the files are very big it is not a good idea to do that every time, so I would like to have a way to choose which file to start from programmatically...

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
adrCoder
  • 3,145
  • 4
  • 31
  • 56

1 Answers1

3

Slice notation can be used in this case:

for f in glob.glob(...)[n:]:
    with open(f) as inputfile:
Community
  • 1
  • 1
kylieCatt
  • 10,672
  • 5
  • 43
  • 51