Hi San,
Thank you for your blog regarding file creation using PYTHON script.
I have a similar requirement.
For testing purpose, I am having sample .py code, which creates a file ( simple dummy file).
But , when I run the job via actions, it's not creating the file ... It runs successfully, but the file is not generating. Kindly help.
In your py code, I can see that you have directly used the "data/" (relative path). How is it picking the file?
I don't see any code in your py code that it creates the file in the current path (data/).
Even I have placed the python code in the same repo path and the file which I want to create also is present in the same path.
Please have a look at my below code.
Python code:
import os
print("Start of File")
cwd = os.getcwd() # Get the current working directory (cwd)
files = os.listdir(cwd) # Get all the files in that directory
print("Files in %r: %s" % (cwd, files))
f = open("/home/runner/work/country_profile/country_profile/QWC.txt", "w")
f.write("Now the file has more content!")
f.close()
print("End of File")
Hi San, Thank you for your blog regarding file creation using PYTHON script.
I have a similar requirement.
For testing purpose, I am having sample .py code, which creates a file ( simple dummy file). But , when I run the job via actions, it's not creating the file ... It runs successfully, but the file is not generating. Kindly help.
In your py code, I can see that you have directly used the "data/" (relative path). How is it picking the file? I don't see any code in your py code that it creates the file in the current path (data/).
Even I have placed the python code in the same repo path and the file which I want to create also is present in the same path.
Please have a look at my below code.
Python code:
import os print("Start of File") cwd = os.getcwd() # Get the current working directory (cwd) files = os.listdir(cwd) # Get all the files in that directory print("Files in %r: %s" % (cwd, files)) f = open("/home/runner/work/country_profile/country_profile/QWC.txt", "w") f.write("Now the file has more content!") f.close() print("End of File")
.yml code: ( I am not using any secrets).
name: Python Test run file
on: push: branches: [ "main" ] pull_request: branches: [ "main" ]
workflow_dispatch:
jobs: build: runs-on: ubuntu-latest