What's the difference between OpenVirtualDisk() and CreateFile() function?
These both does the same work that is opening a vhd file... I want to ask the specific scenarios in which we use these two functions...please correct me if I'm wrong somewhere
See also questions close to this topic
Pypy and numpy in Windows
I am trying to switch from CPython to Pypy to speed up my program (in Windows 10). I managed (don't ask...) to make Pypy work from the command prompt (no IDE then), except it does not recognize numpy or opencv modules no matter what I try. Is there a proven way of installing Pypy, preferably with an IDE (Anaconda, VS Code, PyCharm etc.) to make this work? I spend a couple weeks and counting on Stackoverflow, Pypy.org, etc. to no avail. I want to use the existing Python 3.6 script with minimum modifications. For example, I can try to avoid OpenCV for open/create images and resort to Pypy commands if possible. I don't know if numpy calls can or should be replaced with Pypy commands. If all else fails, I'd have to rewrite the Pypy script without using numpy or OpenCV, which is not nice...
Delete and Replace File Older than 7 Days Python
I want to delete and replace an excel file with the same name if it is older than 6 days. However, when I assess the age of the file based of of os.path.getctime(file_path), the getctime value does not change after I remove and replace it.
I'm not sure if using getmtime or getatime will work because I will be modifying the file in the interim.
import os #check existing excel file stats import time #find creation date of file import openpyxl #excel module import sys #to collect sys args from command line def establish_wb(): file_path = r'C:\Users\cj9250\Documents\this_weeks_blue_stakes.xlsx' if os.path.exists(file_path) == False: #if excel file does not exist wb = openpyxl.Workbook() wb.save(file_path)#create it current_time = time.time() creation_time = os.path.getctime(file_path) #when file was created file_age = (current_time - creation_time)/86400 #number of days since print(file_age) if file_age > 6: #if older than 6 days, replace the file os.remove(file_path) wb = openpyxl.Workbook() wb.save(file_path)#create file print('new one') else:#if younger than 6 days use existing one wb = openpyxl.load_workbook(file_path) print('old one') return wb
Excel VBA code won't open a file named "CON.txt"
I'm processing a large text file with pipe-delimited data in it where each line starts with a text "record type" field--e.g., "APP", "ATT", "CON", "A", "T"... I need to split the file into a series of files with specific record types, so "APP.txt" has all the APP record types, etc.
What I'm doing is reading a line from the source file, grabbing the first field, checking if the token is in a collection and then, if the token is in the collection, opening that file and writing to it, or if the token is not in the collection, creating a new file, writing to it, and adding the token to the collection. My program works fine, except when creating the "CON.txt" file:
If I delete all the "CON" record types out of the source file, it works fine.
If a "CON" record appears on line 2, it bombs out on line 2 creating the file.
If a "CON" record appear on line 50, it bombs out on line 50.
If I add a
pin front of each token so the
CONtokens are now
pCONtokens, everything works fine.
I'm mystified. Any idea why one specific file name would give this program conniptions? The code that actually opens the file (which throws the 75 run-time error) is:
Open sTgtDir & sToken & ".txt" For Append As #iFileNo
sTgtDiris a path ending with "\" that works in all the other cases,
sTokenis the record type token, and
iFileNois an integer based on the count of items in the Token collection.