Read data from .net files in MATLAB

I have a large amount of data that is stored in multiple .net files and I wanted to process them using MATLAB (my current version is R2013a). Despite searching the MathWorks website, I was unable to find any command for importing data from .net files since the ncread command works only for .nc files. An image of the structure of the file(s), after opening with Notepad++, can be seen here.

As can be seen, the file has the data separated by NUL US NUL and starts with US NUL, the Unit Separator and Null characters. I was looking for a method to read in the file such that each of the three entries between the NUL US NUL characters corresponds to the three columns of one row.

One option would be for me to manually open each file with Notepad++ and replace \x00\x1f\x00 with \n, then open the file with Microsoft Excel, delimited by spaces, and save it as a .csv file, which I can in turn import into MATLAB with the csvread command. However, since I have nearly 600 .net files, this does not seem to be a practical solution, simply because of scale of the effort required. I would be really grateful if someone could help me out in this regard and suggest an efficient method to read these files into MATLAB. Thank you so much.


Here is the solution:

function mat=filetrim(filename,'NUL US NUL') % 
if (isunix) % Linux or Mac
    [~, result] = system( ['wc -l ', filename] );
    numlines = str2double(nl);

elseif (ispc) % Windows
    numlines = str2double( perl('', 'your_file') );


r=regexp(strtrim(tline(7:end-6)),pat,'split');% here I assumed that the line ends with
                                              % US NUL. If the line does not end with
                                              % US NUL, please change the "end-6" to
                                              % "end".
for i=1:size(mat,1)
fclose all;

The loop to find out the number of lines in the file was adapted from one of the solutions provided in the "Stackoverflow". The credit goes to @Rody Oldenhuis for this part.

Functions to consider:

Need Your Help

How to update the progressbar with asynctask after re-entrying the activity again in android

android android-asynctask

I'm trying to implement some functions like file downloading which the download kickoff buttons lie in some list view. To make it more clear, here to illustrate it with graph.

Is it possible to simulate other android devices on one of them?

android emulator nexus-7

I want to manually test my android applications on any size and resolution but I have only a Nexus 7. I want to know is it possible to simulate other devices (resolution and screen size) on my Nexu...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.