0

Hai friends
I have a small problem with my code...
I want to copy an existing file (its a model MS Excel file) to a new file & name it with the current date...
First I tried to create the model Excel file, but when I opened it, it had only one sheet inside it, so I tried to copy the existing file, but I couldnt find any bright ideas... can anyone show me a way?


import sys
import win32com.client

fileVM = open('e:/disk/vm.xls','a')
fileVM.close()

The above code creates the file with a single Excel Sheet inside it. But my model file has a lot of info, so I wud prefer to copy & then rename the existing file...

3
Contributors
4
Replies
11
Views
12 Years
Discussion Span
Last Post by xav.vijay
0

are you just looking for a was to copy a file(I might be missing something)

import shutil
shutil.copy2('e:/disk/vm.xls', 'new_name_of_copy')

I have only tested this on my linux system, but it should also work on a windows platform.

0

You may want to use shutil.copy(sourcefile, destinationfile), it gives copy the current date, shutil.copy2(sourcefile, destinationfile) gives the date of the file you copy.

0

You may want to use shutil.copy(sourcefile, destinationfile), it gives copy the current date, shutil.copy2(sourcefile, destinationfile) gives the date of the file you copy.

good point, I was not sure on the exact difference

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.