0

I am doing some data analysis on 120 .csv/.xlsx files. I have to segregate the data. and I have to perform following operation.

" How to save output in .csv after every loop without overwriting in Pandas? "

Each files have different file name.

I don't have Idea about which code should I have to use

1 Answers1

0

Not super sure what you're asking. Something like this?

def main():

    from pathlib import Path
    from contextlib import ExitStack

    with ExitStack() as stack:
        csv_files = [stack.enter_context(path.open()) for path in Path(".").glob("*.csv")]
        # Do stuff with csv_files

    return 0


if __name__ == "__main__":
    import sys
    sys.exit(main())
Paul M.
  • 10,481
  • 2
  • 9
  • 15