0

I am trying to name clips from a moviepy ffmpeg output based on text in dataframe columns. I can create the clips but am having trouble with the naming as Im not sure how to loop through the list and add it to the output file name.

example data frame

import pandas as pd

data = [["Park","Road",4, 10], ["Road","Street", 80, 95], ["Street","Park",120, 132]] 
df = pd.DataFrame(data, columns = ["Origin", "Destination","Start", "End"])

print (df)

Origin| Destination| Start | End

0 | Park | Road | 4 | 10

1 | Road | Street | 80 | 95

2 | Street| Park | 120| 132

Id like the output file to show the Origin and Destination text

videoParkRoad1

videoRoadStreet2

videoStreetPark3

the code I have at the moment

filename="D:\video" + str(i+1) + ".mp4"

returns

video1

video2

video3

Hope this makes sense

Thanks

Witness
  • 15
  • 5

1 Answers1

1

Code:

import pandas as pd

for i in range(len(df)):
    filename = "video" + str(df.iloc[i,0]) + str(df.iloc[i, 1]) + str(i+1)
    print(filename)

Output:

videoParkRoad1
videoRoadStreet2
videoStreetPark3

I hope it would be helpful.

Littin Rajan
  • 852
  • 1
  • 10
  • 21