I'm trying to get path in python to open and write in text document by already exist path directory C:\ProgramData\myFolder\doc.txt, no need to create it, but make it work with python executable on user computer. For example if this way I got folder there:
mypath = os.path.join(os.getenv('programdata'), 'myFolder')
and then if I want write:
data = open (r'C:\ProgramData\myFolder\doc.txt', 'w')
or open it:
with open(r'C:\ProgramData\myFolder\doc.txt') as my_file:
Not sure if it is correct:
programPath = os.path.dirname(os.path.abspath(__file__))
dataPath = os.path.join(programPath, r'C:\ProgramData\myFolder\doc.txt')
and to use it for example:
with open(dataPath) as my_file: