I've got a folder of images and want to iterate through them so I can write data corresponding with each to a csv file. The image directory contains four images but an error is thrown at the third image ('Loss Label_0_2.tif'). Note the directory containing all images is in a folder called DS_Test (see dataset_dir). But, with the error I get, it seems it starts searching in the parent directory (CNN) rather than CNN/Dataset_dir, specified in dataset_dir.
Could anyone tell what mistake I'm making?
I took the parent directories above CNN out of the path for privacy reasons. Apologies if this question is a bit of an overload of info.
dataset_dir = 'directorypath/CNN/DS_Test/'
with open('csvfilepath/Labels.csv', 'w') as file:
writer = csv.writer(file)
for image in os.listdir(dataset_dir):
if image.endswith('.tif'):
*
series of file operations
*
writer.writerow(data)
file.close()
Error: "FileNotFoundError: [Errno 2] No such file or directory: 'directorypath/CNN/Loss Label_0_2.tif'
Related
I have created cmd batch file to run several R script and each script have their own log files in same folder like below :
coc_prod_xgb.log
ds_prod_xgb.log
ccpa_prod_xgb.log
pletb_prod_xgb.log
and many more
Then I merge all text files into 1 log file
copy *.log all_log.log
The problem is sometimes there are errors on different jobs, so I need to know on which log this error occurs. Currently I have to open each log file one by one, because in the merged log file, I can't identify which log file that has this error.
How to modify above copy code so it will write file names on the 1st row then the next row will be log information and append the same process to next file
I can't find any option for cmd copy code to write file name, so i find another solution from this question.
Easiest way to add a text to the beginning of another text file in Command Line (Windows)
so it serve my needs, eventhough i have to write each block of code for each log file. but only for 1 time effort
I have a Move file component in my flow:
<sub-flow name="MoveFileToErrorDirectorySubFlow" doc:id="51f387ca-5faa-4ba4-af87-008a1698e104" >
<file:move doc:name="MoveFileToErrorDir" doc:id="c99d732d-2fc5-4512-b50d-c97c9b4e8aff" sourcePath="${invoices.import.path}" targetPath="${invoices.error.path}" config-ref="XMLFile"/>
</sub-flow>
invoices.import.path is pointing to /home/user/invoices/import/invoice
invoices.error.path should be pointing to /home/user/invoices/import/invoice/error
But when I am trying to run the flow by pasting a file into /home/user/invoices/import/invoice/
I get an error:
Message : An error occurred while executing 'move' operation on file '/home/user/invoices/import/invoice' to '/home/user/invoices/import/invoice/error/invoice': Cannot move directory: /home/user/invoices/import/invoice to a subdirectory of itself: /home/user/invoices/import/invoice/error/invoice
First thing, why I am getting an error:
java.io.IOException: Cannot move directory: /home/user/invoices/import/invoice to a subdirectory of itself: /home/user/invoices/import/invoice/error/invoice
Second thing, why the target directory is /home/user/invoices/import/invoice/error/invoice instead of /home/user/invoices/import/invoice/error
Third thing, i am trying to move a file but it seems that it is trying to move a whole directory - to a wrong path as mentioned above...
What am I doing wrong here?
It seems that you are trying to move a directory (/home/user/invoices/import/invoice) instead of a file inside that directory (let say /home/user/invoices/import/invoice/report.csv as an example). The connector expects sourcePath path to be the path to the file, including the file name. The extension is part of the name by the way so don't miss it.
On the other hand, targetPath is expected to be a directory.
That explains all the issues.
Your sourcePath points to a directory. You can not move a directory into one of its own subdirectories. That doesn't make sense in any file systems I know of.
Because it is trying to move /home/user/invoices/import/invoice into /home/user/invoices/import/invoice/error, the resulting target would be to create an invoice sub directory of the error subdirectory, or /home/user/invoices/import/invoice/error/invoice.
I'm trying to load files into MAGMA and am running into some trouble. Ostensibly, the command load "filename";should be sufficient. I've attempted, but keep getting the same result:
>> load "filename";
^
User error: Could not open file "filename" (No such file or directory)
The file is saved in my documents folder, so I'm not sure what the issue is. Do I have to specify the path? Save the file in a particular place?
I've tried reformatting, using both txt and rtf files, so I don't think that's the issue.
For loading file in MAGMA you can place your file in installed place folder. For example: C:\Program Files (x86)\Magma
Also if your file have an special format you should mention it.
Suppose You want loading a txt file with name a. with load"a"; you face with error. You must type load"a.txt";.
Try using GetCurrentDirectory() command to find your current directory location. And then you can use SetPath() to change where MAGMA has to be to search for your file. This will fix it.
"The specified path, file name, or both are too long.
The fully qualified file name must be less than 260 characters,
and the directory name must be less than 248 characters"
That is the error whenever I try to move a file from one folder to other.
The same file is getting loaded into a table but when I try to move, its throwing the error.
I am using a file system task to move the file from one folder to another. The file system task is throwing out that error.
Did anyone encounter the same error? How did you overcome? Please help me solve this error..
There is a tool to address just this. Can be found at http://PathTooDeep.com
Alternately you can use expressions to rename and move the file using a File System task.
i find that to play video files using mediaelement, we need to set the file's Copy To Ouput Directory to Copy Always. is there any option to auto delete the file from the output directory after it has been used? because if there's hundreds of video that has been played by the application, then it will take a massive amount of storage, right? because from what i seen, this copy to ouput directory will create the duplicate of the files, from it's original source path. please enlighten me
You do not need to copy the files to the output directory, you can set the source as follows:
mediaElement.Source = new Uri (System.IO.Path.Combine(dirWithVids, fileName)
,UriKind.RelativeOrAbsolute)