import scipy.io as sio
# read a .mat file
animal = sio.loadmat("animals.mat")
# sample output
{'__header__': b'MATLAB 5.0 MAT-file, Platform: GLNX86, ...
'__version__': '1.0',
'__globals__': [],
'names':
'features': a
}
This simple line of code can be used reading .mat file without MATLAB installed in your computer.
Showing posts with label read. Show all posts
Showing posts with label read. Show all posts
How to read .mat file without using matlab (using Scipy library in Python)
How To Read File In Java – BufferedReader
JDK 7, read file in Java and automatically close the file.
1: BufferedReader br = new BufferedReader(new FileReader(file_path));
2: String text="";
3: String currentLine;
4: while ((currentLine = br.readLine())!=null){
5: text = text+currentLine;
6: }
How to read n-quads file? Jena read n-quads file with model size zero?
Reason : A Jena Model is a single graph and it can't hold named graphs (which are in n-quads file)
Solution : Use DataSet to get the set of all graphs in n-quads file first and use model to get every set.
Solution : Use DataSet to get the set of all graphs in n-quads file first and use model to get every set.
1: public static void main(String[] args) {
2: // print every Model(Graph) size in n-quads file
3: Model model = ModelFactory.createDefaultModel();
4: Dataset dataset = RDFDataMgr.loadDataset("sample.nq");
5: Iterator it = dataset.listNames();
6: while(it.hasNext()){
7: String graphName = (String) it.next();
8: model = dataset.getNamedModel(graphName);
9: System.out.println(graphName+":"+model.size());
10: }
11: }
Subscribe to:
Posts (Atom)