How can I read a HDF file if I have save the hdf file as dtype of float32? - extract

I have explored hdf5 to save many different labels of different audio files. The size of the y-valid is (800, 16) and it has the float32 dtype. The save of y_valid under hdf5 was successfully made, but when I wanted to read y_valid.hdf5 an error was occurred mentioning that type is not supported. The python code for saving under hdf5 is below.
From other side, an error was occurred when I tried to save (write) y_valid under hdf5 with dtype=object.
Please, help me to write and then read correctly y_valid.hdf5.

Related

Unable to extract csv file from mat file in octave

I need help to extract this particular file marked with an arrow in a csv format in the original structure, please help me out with proper line of codes.
Thank You.
Octave has a save command that can save a matrix in a number of different formats. You can try a binary format, or R and Python can read HDF5 files.
https://octave.org/doc/v4.0.0/Simple-File-I_002fO.html

Not able to load file formats other than MATLAB files in Octave

Octave can easily load MATLAB files, for example load('names.m'). But while trying to load file formats other than MATLAB file format like load('names.txt') I am getting an error:
error: load: unable to determine file format of 'names.txt'
Octave supports matlab file formats . But to load text files use the following code in terminal load('-ascii','names.txt'); This will load the text file without showing any error.

Error when reading graphml file in r graph

I'm trying to read a graph ml file in r using the i graph package.
The code I'm using is the following
g<-read.graph("graph_bustuberail_london_500m",format=c("graphml")) #import gml
I get the following error message
Error in .Call("R_igraph_read_graph_graphml", file, as.numeric(index), :
At rinterface.c:5866 : Cannot open GraphML file, File operation error
Not sure why this is not loading in, can anyone help me?
Igraph is not very informative regarding certain types of error it displays: I have found that many times the above error is caused by simply a misspelling in the filename.
As a consequence I suggest you to start by checking that you have written the file extension correctly, i.e. with .gml ending and not with .glm.

decompressing huge json gzip file causing memory error in python

I got the following problem.
I am working with small machine with low memory (1 GB).
my program download a huge gzip file from some url. And I need to decompress it to dict I know for sure that the file is in json format.
My problem is that after I run the following command I got a memory error:
data = zlib.decompress(url, 16 + zlib.MAX_WBITS).decode('utf8')
results_list.append(json.loads(data ))
now for small files this works fine, but for large I got the error.
my intuition tells me that I should split the file into chunks, but then because I am expecting a json file i wont be able to restore the chunks back to json (because each part wont be a valid json string).
what I should do?
Thank a lot!
Create a decompression object using z=zlib.decompressobj(), and then do z.decompress(some_compressed_data, max), which will return no more than max bytes of uncompressed data. You then call again with z.decompress(z.unconsumed_tail, max) until the rest of some_compressed_data is consumed, and then feed it more compressed data.
You will need to then be able to process the resulting uncompressed data a chunk at a time.

Spark CSV Handle Corrupt GZip Files

I have a spark 2.0 java application that is using sparks csv reading utilities to read a CSV file into a dataframe. The problem is that sometimes 1 out of 100 input files may be invalid ( corrupt gzip ) which causes the job to fail with:
java.lang.IllegalStateException: Error reading from input
When I used to read the files as text files and manually parse the CSV I was able to write a custom TextInputFormat to handle exceptions. I can't figure out how to specify a customer TextInputFormat when using spark's CSV reader. Any help would be appreciated.
Current code for reading CSV:
Dataset<Row> csv = sparkSession.read()
.option("delimiter", parseSettings.getDelimiter().toString())
.option("quote", parseSettings.getQuote())
.option("parserLib", "UNIVOCITY")
.csv(paths);
Thanks,
Nathan