0

I have script that run over file for each "task" - unique id in my input table. After process, I want to write my output frame as file with name of task separately for each task. For example: task1.scv, task2.scv and so on.
my code that doesn't work:

for t in range(0,len(cv_tasks)):
      <...some process..>
df.to_csv('%s.csv' % cv_tasks[t])

1 Answer 1

1

Here is possible simplify your task:

for i, t in enumerate(cv_tasks):
    print (i)
    print (t)
    <...some process..>
    #indentation necesary
    df.to_csv(f'{t}.csv')
Sign up to request clarification or add additional context in comments.

2 Comments

I also use value 't' as assign : n_rows = int(frame.loc[frame['task']==cv_tasks[t],['last_frame']].to_numpy())+1 , so in you code raise KeyError(key), I stil need save t as integer. When I change code to frame.loc[frame['task']==t, it;s no error but still make only one file
@TeoK - Added i for integers. Answer was edited.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.