How can I read xlsx files into Octave matlab? - octave

So, I tried to read xlsx file using readtable function in Octave, but it put out a warning message "the 'readtable' function is not yet implemented in Octave". So, what is the way I could possible read xlsx files in Octave?

This will be a very late answer, but I am writing to provide a solution for those who have this problem in the future.
To read .xls files, you need the octave io package because this package includes "xlsread()" function. You can check if you have this package by typing "pkg list" in the octave console. Then, at the beginning of the code, you should write the command "pkg load io". You can now use the xlsread() function.
The outputs of the xls and readtable functions are not exactly the same, so you have to make changes to the output.
io package:
xlsread function:

Related

Dymola conversion script, run script manually

I have a library without annotation (uses(Modelica(version="X.Y.Z"))); in the top level package.mo file. Can I manually execute the conversion script to update my library? And where is it located? I am using Dymola.
Conversion scripts are usually located in the Resources folder of a library.
E.g. for the MSL 3.2.3 shipped wit Dymola 2020x, you can find them here:
C:\Program Files\Dymola 2020x\Modelica\Library\Modelica 3.2.3\Resources\Scripts\Dymola
To manually apply a conversion:
Open a fresh Dymola window
Run the conversion script
via the GUI with Run Script in the Simulation tab
or from the command line with RunScript("path/to/conversion.mos")
Open the library to convert
Dymola will directly apply the conversions and you will not see the usual conversion dialog. Check the log window to see what was converted.

Open a html file inside a zip file. Python 3.6. TypeError: 'ZipFile' object is not callable.

I am learning about python and I want to open a html file inside a zip file. I'm reading tutorials and following documentation I found online for python 3.6 but I can't print the content of the news.html document which is inside the John.zip folder
import zipfile
file = zipfile.ZipFile("John.zip", "r")
with file('John.zip') as myzip:
with myzip.open("news.html") as myfile:
print(myfile.read())
When I start without debugging it shows "TypeError: 'ZipFile' object is not callable
But I can't fix this. I tried simpler things such as trying to open it the way you open a .txt file
file=open("John.zip/news.html")
print(file.read())
this didn't work either
What you are doing is storing a ZipFile as an object named it "file". Then, in the line beginning with "with", you're calling it as if it were a function. That is why you received the TypeError, because that object you named "file" is not a callable function.
Get rid of the line where you stored it as "file", and try something like this:
with zipfile.ZipFile('John.zip', 'r') as myzip:
Source:
Python Docs: https://docs.python.org/3/library/zipfile.html#zipfile-objects
I guess you have overridden the builtin function "file" by setting the global variable "file".
just print the file see whats in it.
TypeError: 'ZipFile' object is not callable
I had the similar problem, in my case i was working on google colab and i was getting this error but i updated the tensorflow version to v2.0.0 from v1.5.0 and it worked.
If the problem is not resoöved even after updatíng the tensorflow then try update to higher python version or lower python version sometimes, hope it would be solved.

How to use ceylon js (also with google closure compiler)

Calling a file resulting from the concatenation (bash: cat ... >> app.js) of the following three files:
/usr/share/ceylon/1.2.0/repo/ceylon/language/1.2.0/ceylon.language-1.2.0.js
modules/com/example/helloworld/1.0.0/com.example.helloworld-1.0.0-model.js
modules/com/example/helloworld/1.0.0/com.example.helloworld-1.0.0.js
with the command nodejs app.js does nothing. The same when used in a web page. How do have I to call that javascript program so that it runs without using require.js ?
Please give the rules how ceylon modules and the run function and other functions contained within translate to javascript and are to be called.
How can I get one javascript file from compilation of several ceylon modules without concatenating them manually or with require.js?
The above is without using google closure compiler.
Given the size of 1.6 MB of the language module, it makes no sense to run ceylon-js without using google closure compiler.
Compiling "ceylon.language-1.2.0.js" alone with google closure compiler results in a lot of warnings.
java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js /usr/share/ceylon/1.2.0/repo/ceylon/language/1.2.0/ceylon.language-1.2.0.js --js_output_file lib-compiled.js
How can I get rid of those warnings?
In what order do I have to chain together files resulting from ceylon-js with the model file and the language file to compile them in advanced mode with google closure compiler for dead code elimination.
These are 3 questions, really.
A Ceylon module is compiled to a CommonJS module. Concatenating the resulting files won't work because each file is on CommonJS format, which is a big function that returns an object with the exported declarations.
You can compile the modules with the --no-module option to get just the generated code, without it being wrapped in CommonJS format. For the language module, you can copy the file and just delete the first line and the last 5 lines.
I do not yet know how to get rid of the warnings you mention in the second question.
And as for the third question, I would recommend putting the language module first, then the rest of the files. If you have any toplevel declarations with the same name in different modules, you'll have conflicts (only the last declaration will remain), even if they're not shared, since they're all in the same module/unit.
Well, I think require.js can run the compilation of the modules to one file and then run the google-closure-compiler, see: http://www.requirejs.org/docs/optimization.html

In Octave, how do you source a file if the file name is stored in a variable?

I feel like this must be very easy, but I can't find the answer anywhere. In octave (and probably matlab but I haven't verified), you can source the contents of a file by doing
source /path/to/filename
However, let's say I have the filename stored in a variable called file. If you do source file, it treats file as the path rather than what is stored in file. I have tried inserting eval in various places but if that is the answer, I haven't found the correct invocation. I don't know much octave; there is surely a trivial answer to this that I am overlooking?
Not sure about octave, but try to use a function call
source(fname)
That's what you do in matlab at least.

get data from .csv file, analyze, produce output - python3

I am trying to complete an assignment in Python3. It is very similar to the pdf found here
I have a few questions on both the execution of how to get the information I need, and if possible, some code that could move me along. I am new to python. As right now from the code I have, I keep getting the error "directory not found" after running a function to try and read the data. I know the .csv file should be in the directory where I save it to in WingIDE, but I can't get it to work correctly.
My first question is after getting each line of the .csv file to read from my get_file_list, what is the best way to take each category and throw it into an efficiency equation?
Here is my get_data_list function:
def get_data_list(filename):
data_file = open(filename, "r")
data_list = [ ]
for line_str in data_file:
data_list.append(line_str.strip().split(','))
return data_list
when I run get_data_list("player_regular_season.csv") I get the following error:
builtins.IOError: [Errno 2] No such file or directory:'player_regular_season.csv'
For the first try, you can put the data file to the same directory with the Python program and launch it from the directory.
Try also a single purpose script to learn how to work with directories. Learn the functions from the standard doc 15.1.5. Files and Directories, namely os.getcwd(), os.chdir(path), and then 10.1. os.path — Common pathname manipulations, namely os.path.isfile(path).
But read also the doc of other functions in the documents to learn what is available.
When knowing how to work with filenames and paths, have a look at the 13.1. csv — CSV File Reading and Writing. Not to be scared of all the stuff, start from the end -- 13.1.5. Examples of using the csv module.