Hi everyone … I’m trying to upload my challenge solution in .m (octave or matlab) and has presented the error show un the image
Do you know what this error means ? and how can I fix it ?
Hi everyone … I’m trying to upload my challenge solution in .m (octave or matlab) and has presented the error show un the image
Do you know what this error means ? and how can I fix it ?
Your error:
error: dlmread: unable to open file 'DATA.lst'
You may read about dlmread() and why that can fail in Octave, or found a workaround.
you can found a little workaround Here but is probably that you want another thing, knowing the error try to figure out how to solve it
When I run the code in Octave it doesn’t failed
the file DATA.lst is in the directory but it seems that can’t find it
You can find this:
In the link that I put before, is probably that you don’t have read permission when the CI runs, or maybe you aren’t using the same flags that the compiler in the repo uses.
In this image you can see the function compile for octave.
I don’t know much about octave, I only know that your problem is related with the dlmread() function, I can help only say that, find the workaround or solutions that suits to you is your job, I think that you can try with csvread() or fopen(), or try to figure out why dlmread didn’t work or make with inputs, that is the better way, because when you upload it you must use:
cat DATA.lst | <your code>
I was thinking about that and is probably that the file DATA.lst didn’t exist in the derivations that nix build, and for that reason is probably that octave can’t open a file that didn’t exist, but is a supposition, I will try to investigate if that supposition is true and I will tell you, but if it is true, you may change dlmread() for fopen() and handle the error when the file didn’t exist.
I changed dlmread to fopen(), The issue persists, but there is more info
the file DATA.lst didn’t exist in the derivations that nix build,
—> it’s exactly what is happening. This can be fixed ? do you how ? could you let me a clue ?
I was looking around other challenges’ solutions in Octave and found that has the input data hardcoded into the solution, which it is no allowed (or with Octave is allowed ?)
I don’t know if it is a good idea but, Can you read the input of your program from standard input? and then execute your program like cat DATA.lst | ./script.m. Is that possible?
Is the better way, because I think that is probably that you can’t read the file when the derivation was build, but if can be solved making a handle when the program didn’t find any file or can’t open it.
2 ways:
read inputs, no files, with that way you can use cat DATA.lst | <run your file here>
this is the accepted way in the repo, because open the file was deprecated (1 month ago you can open the file).
handle the error when fopen = -1 with something like: if fopen == -1, exit or close or print error.
An important part of this process is that you try to learn how to handle errors, not only pass the checks, for example, what happen if you have a function that get some params like a string, but when the function is calling the string for some reason Is null?
That example is exactly what happens with the file, you can fix that handle the error when the function receive unexpected things (or receive nothing).
This is related to your error, but is better that you try to use inputs because in the repo they want that you can send the Data like an argument.
(You can mix the inputs with a file with a function that work with inputs if receive any argument, if not, that work with a file, you can see an example of that searching some solutions with this name: richardalmanza.cr).