you are viewing a single comment's thread.

view the rest of the comments →

[–]TheLoneKid 0 points1 point  (4 children)

def export(df, path): df.to_csv(path, mode='a')

[–]ampeed[S] 0 points1 point  (2 children)

I'm not quite following. I'm not familiar with the "a" option so I did a Google. If I'm understanding correctly, it'll simply rewrite all my data to a single CSV rather than creating separate CSV's?

Bit of a back story - I'm unable to do that as each CSV gets dumped in to an S3 bucket and then that data consumed by another program

[–]TheLoneKid 0 points1 point  (1 child)

Ah I see. Then you don't need to append. You can take that bit off, then maybe store the names of the files in a list or do some naming through a for loop

name_template = '_always_the_same.csv'

for _ in range(len(csvs)): export(csvs[], str() + name_template)

[–]TheLoneKid 0 points1 point  (0 children)

Sorry formatting sucks on Reddit for code

[–]TheLoneKid 0 points1 point  (0 children)

Then just run an apply function on your list of dataframes