0
source = ('C:\\AutoTransInt\\Input\\oplog\\*.csv')
destination=("C:\\AutoTransInt\\Input\\excel")

How to perform copy operation for above line using

copyfile(source,destination)

i am getting error when i tried to do this

Madhums
  • 1
  • 1
  • 5
  • Does this answer your question? [python copy files by wildcards](https://stackoverflow.com/questions/18371768/python-copy-files-by-wildcards) – Azeem Apr 02 '20 at 09:33

2 Answers2

0

You can use "shutil" that has many methods you can use. One of which is:

from shutil import copyfile
copyfile(src, dst)

you just has to add your source file to src object and destination file to dst object.

Description is as follow:

  1. Copy the contents of the file named src to a file named dst.
  2. The destination location must be writable; otherwise, an IOError exception will be raised.
  3. If dst already exists, it will be replaced.
  4. Special files such as character or block devices and pipes cannot be copied with this function.
Zubad Ibrahim
  • 371
  • 2
  • 14
0

you can also use copy2 function of same library. example:

import shutil shutil.copy2('/src/dir/file.ext', '/dst/dir/newname.ext') # complete target filename given shutil.copy2('/src/file.ext', '/dst/dir') # target filename is /dst/dir/file.ext

Zubad Ibrahim
  • 371
  • 2
  • 14
  • problem here is i am not passing file name i want copy once it is created so only giving "C:/path/*.csv" above code is not working for me – Madhums Apr 02 '20 at 13:37