Issue
I am trying to select data in MySQL JDBC in MATLAB. One of the columns (file_data) in the table has the type "longblob". More details of the content of the file_data is shown on the picture below.
src="https://i.stack.imgur.com/a2Wav.png" alt="file_data content with type longblob">
The two first lines are the header, and the remain-rows are the data. Before I save this file into the database MySQL (using spring-MVC and JSP), the file is a CSV file, which has delimiters ";".
The picture below is the table of the database. You can see the type of column file_data is "longblob".
But why when I try to preview the database in database explorer in MATLAB, it should be blob, but it showed "int8". More details please look at the picture below.
According to that, I have questions:
How make the file_data can be read in MATLAB as "longblob" and not "int8"?
if the column "file_data" already successful change to longblob, how to read it as a table, so make me possible to process the data?
Solution
CountOfBytesx1 Int8
is equal to longblob. Int8 is the Matlab Byte
and CountOfBytes is the number of bytes stored.
You can convert it back to a file with something like:
fid = fopen(file_name,'w')
fwrite(fid,file_data,'*int8')
fclose(fid)
Code from matlab answers. Where file_name
and file_data
are the fetched values from your query.
Alternatively, you can try one of the solutions of Retrieve blob field from MySQL database with MATLAB
To read the CSV-Data use csvread
When you have solved your question, add the solution to your cross post too.
BTW: I never used Matlab
, but a simple websearch for Matlab int8 longblob
guided me.
Answered By - ComputerVersteher
Answer Checked By - David Marino (JavaFixing Volunteer)