path

How do I normalize a path format to Unix-style while on Windows?

How do I normalize a path format to Unix-style while on Windows? Question: I am storing paths in a json file using a python script. I want the paths to be stored in the same format (Unix-style) no matter which OS the script is run on. So basically I want to run the os.path.normpath function, …

Total answers: 2

File not found error when copying images from one folder to another

File not found error when copying images from one folder to another Question: I have a text file containing the names of images to be copied from a source folder to a destination folder. The source folder contains several sub-folders as shown below. The images may come from any of these sub-folders. animals (source folder) …

Total answers: 1

Imported function not finding filepath when used in jupyter notebooks

Imported function not finding filepath when used in jupyter notebooks Question: I have the following folder setup: project ├── pipeline │ ├── functions.py | ├── __init__.py | └── library │ └── data.csv | └── notebook.ipynb I import my functions.py into the notebook as follows: from pipeline.functions import * In my notebook I use one of …

Total answers: 1

Rename all csv files in folder by removing the end of the filename

Rename all csv files in folder by removing the end of the filename Question: I have an entire data folder ending with .csv. All csv files are named like this : "data_AA_10_344362.csv" "data_AA_25_124567.csv" "data_AA_37_896432.csv" etc. I want to rename all of them by removing everything after the last underscore but keep ‘.csv’. So i would …

Total answers: 2

Import modules from Airflow

Import modules from Airflow Question: Need help importing modules from dags. I have a dag, next to which in the same folder is my python script. For some reason airflow does not see this file and it shows import error. Below you can see that status_dict.by is next to my dag. I partially solved the …

Total answers: 1

Python add path of data directory

Python add path of data directory Question: I want to add a path to my data directory in python, so that I can read/write files from that directory without including the path to it all the time. For example I have my working directory at /user/working where I am currently working in the file /user/working/foo.py. …

Total answers: 2

Add an empty string to a path

Add an empty string to a path Question: I want to add an empty string to a path. Let me place my code so you can better understand. inpDir = r"C:/User/Folder" flag = 1 if flag == 1: path_str = ["/1", "/5", "/12", "/54", "/76"] else: path_str = [] for i in path_str: inpDir = …

Total answers: 1

python: opencv,some issue when count pixel

python: opencv,some issue when count pixel Question: I use opencv to count the number of white and black pixels of picture(I have convert them into black and white image), and everytime I run my code it return the number is 0,and the code is output_path = "/content/drive/MyDrive/dataset_demo/result_pic" for pic in os.listdir(output_path): if pic.endswith(‘.jpg’): image = …

Total answers: 1

How to load fonts from GCS(problem solved)

How to load fonts from GCS Question: I want to load "fonts" from Google Storage, I’ve try two ways, but none of them work. Any pointers? Appreciated for any advices provided. First: I follow the instruction load_font_from_gcs(uri)given in the answer here, but I received an NameError: name ‘load_font_from_gcs’ is not defined message. I installed google …

Total answers: 1