0

my current code does:

  1. open .dat file, split them into smaller .dat files by group

newpath = r'C:\Users\DELL\Desktop\python split\462888'
if not os.path.exists(newpath):
    os.makedirs(newpath)

with open('462888//462888.dat', 'a', encoding='utf-8') as outfile:
    for filename in path.glob(f"*{extension}"):
        with open(filename, encoding='utf-8') as infile:
            for line in infile:
                if '4628 88' in line:
                    outfile.write(line)

what i want to do:

how do i move the opened .dat files into a new folder after it finished processing into smaller .dat files to avoid duplication.

Miko Efa
  • 33
  • 4
  • 1
    Does this answer your question? [How to move a file in Python?](https://stackoverflow.com/questions/8858008/how-to-move-a-file-in-python) – Christian Karcher Oct 11 '22 at 08:14

0 Answers0