Binary File Reader to a Chart
Hello All,
Newbie having some trouble with reading a chart from a binary file. My problem may be with trying to use a binary file, I am not sure. The x axis time is not the same length as the actual test time. I have acquired a rms voltage from a VCR RF envelope. I'm using a 6009 DAQ with LV 7.1 on Win2K. I have attached the recording vi and the reading vi and a sample file. I have tried different things including the examples that came with lab view. I need to write a small sized file because this test will last for 4 hours. I have another application that will run for 5 days. I appreciate any help or ideas.
Thanks,
bh3560
Attachments:
Chart write_Read.zip 140 KB
Hi,
The program you have attached acquires, saves and reads data in ASCII ( floating numbers) and not binary.
To get an idea on how to write and read data in binary format, look at attached examples( taken from examples shipped with labview)
Hope this helps
Regards
Dev
Attachments:
Cont Acq&Graph Voltage-To File(Binary).vi 88 KB
Graph Acquired Binary Data.llb 72 KB
Similar Messages
-
Hello everyone,
I am not that comfortable with binary file reading. I am trying to learn.
I have a vi which logs a sine wave in a binary file.
The Read vi which I have written is not giving the expected data.
Thanks in advance
cooldude
Attachments:
Log Data.vi 9 KB
Read Data.vi 10 KBAttachments:
Log.JPG 20 KB
Read.JPG 13 KB -
I tried to read one line of binary file as the top of the screenshot.
The result is as the left side. It shows the first part with text are correct. The ending part is not match with the raw one.
I also tried read by byte, but still the same.
Any suggestion, thanks.
Solved!
Go to Solution.
Attachments:
shot.JPG 48 KBWhat program created this binary file?
If you can figure out how the file was created, then you can figure out how to read it.
We can't help because all you've shown are some bytes and say that some are right and some are wrong. What is the "raw one" you are referring to? What do you expect it to look like?
Message Edited by Ravens Fan on 01-26-2010 11:15 PM -
Binary file read with bit offset..not byte offset.
hi,
i want to read a binary file with some offset ..not in bytes... offset in bits..my data is a single bit data stream size of 1GB ,after skipping particular bit offset i want to read the data in byte order..
Indrajit
| [email protected] | [email protected] .hi , Gerd W
i am not able to follow your answer.... here with i attached a file to describe my query more clearly. Actually two channels of 1 bit data stream stored in two different files ,and the file size will be more than 10 GB.
i want to delay the channel B by 3 bits and i want to perform bitwise operation between channel A and shifted version of channel B..till the end of the data..
now i am doing this without applying any delay by choosing a small block by block which corresponds to 1 sec of data .
Indrajit
| [email protected] | [email protected] .
Attachments:
bitwsie.png 16 KB
bitwsie.jpg 52 KB -
Binary file readed from Labview and Borland C++ v.5
Hi Everybody!
My problem is reading binary file from Labview 7.0 and Borland C++ version 5 is not the same.
Only one difference is "space". Reading from Labview I got "00" (decimal) and reading from Borland C++ I got "32".
I also try to read this binary file with Matlab 6 and I also got "00" as well as those from Labview.
I really struck with this problem.. Anybody has an idea about this problem.
Thanks a lot for anybody help!
NokHi,
These threads regarding reading of binary files was recently discussed in this forum
You might find some answers for your query
http://forums.ni.com/ni/board/message?board.id=170&message.id=99016&requireLogin=False
and
http://forums.ni.com/ni/board/message?board.id=170&message.id=153565&requireLogin=False
Regards
Dev -
Dear All,
I have Binary file. I want to read Bytes based on Patterns and each channel value (Byte values -- > Float conversion) and storing it into Index array.
Please check the attachment for pattren format.
Here, the biggest problem is we will get only pattern style, Based on pattern the data is already stored in Binary file just we need to read it means we need to set the Timestamp based on this.
Please give me some idea to read this kind of pattern files.
BR,
Guru
Munna
Attachments:
Data Reading.xlsx 15 KB
Data Reading.xlsx 15 KBHi Munna,
that pattern is quite hard to understand. It seems there is some information missing…
In your pattern table the data size for e.g. ch1 is given as "1 byte", but in your time schedule you use two bytes for ch1. How are those "ch start position bytes" to be identified?
Byte values -- > Float conversion
How do you want to convert those bytes to Float (SGL or DBL)?
storing it into Index array
What is an "index array"?
It seems you have to create a table from your pattern which identifies the bytes in the file. That seems to be the trickiest part as in your pattern#2 example you already have made a mistake (for ch4 there is no marking at timestamp 70ms)…
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Hi there,
I'm trying to read a partially binary file with the following structure: The first three lines of the file are regular strings (one can see them correctly when opening the file in a text editor), the rest of the file's contents are integers in their binary form (one cannot see them correctly when opening the file in a text editor).
How can I read such a file?
Thanks in advance!
+P.S.: If you're interested, I'm trying to read a .PPM file (look here to find out about the format).+pfrc wrote:
Hi there,
I'm trying to read a partially binary file with the following structure: The first three lines of the file are regular strings (one can see them correctly when opening the file in a text editor), the rest of the file's contents are integers in their binary form (one cannot see them correctly when opening the file in a text editor).
How can I read such a file?
Thanks in advance!
+P.S.: If you're interested, I'm trying to read a .PPM file (look here to find out about the format).+Use a BufferedInputStream wrapped around a FileInputStream. Read and bytes and until you've hit two end-of-lines, then put those bytes into a String constructor. Note that you'll have to know which line end convention is used, or write your code so as to allow for any of the common ones. After that, continue reading bytes and processing however is appropriate for you. -
Hi,
I'm currently using a java.io.BufferedInputStream to read a large binary file.
I recently discovered there is a chunk of data that shows up near the end of each file. (these files are binary and are XX to XXX mb in size)
Loading it all to memory first would kill my performance so I'd like to be able to come up with an alternate method.
Does Java or the class above offer a way I can
1) get the length of the file
2) seek to a point say 2000 bytes from the end so I can start reading the binary data?
Ideally I'd like to do a backwards read as that would be quickest. Is there a way to change the operation so that a 'read' would be reading backwards (from end to beginning)?
For me speed is the #1 thing i have to worry about. So to be able to seek forward several hundred thousand bytes at a time would help tremendously.how does the 'skip' method work? Probably by using OS specific calls to read to a point in the file.
maybe I could
'skip' length - 20k from the start or something like
that.
Yep. -
Blob for binary file, read/write problems
Hi,
I am relatively new to this type of development so apologies if this question is a bit basic.
I am trying to write a binary document (.doc) to a blob and read it back again, constructing the original word file. I have the following code for reading and writing the file:
private void save_addagreement_Click(object sender, EventArgs e)
// Save the agreement to the database
int test_setting = 0;
// create an OracleConnection object to connect to the
// database and open the connection
string constr;
if (test_setting == 0)
constr = "User Id=royalty;Password=royalty;data source=xe";
else
constr = "User ID=lob_user;Password=lob_password;data source=xe";
OracleConnection myOracleConnection = new OracleConnection(constr);
myOracleConnection.Open();
// create an OracleCommand object to hold a SQL statement
OracleCommand myOracleCommand = myOracleConnection.CreateCommand();
myOracleCommand.CommandText = "insert into blob_content(id, blob_column) values 2, empty_blob())";
OracleDataReader myOracleDataReader = myOracleCommand.ExecuteReader();
// step 2: read the row
OracleTransaction myOracleTransaction = myOracleConnection.BeginTransaction();
myOracleCommand.CommandText =
"SELECT id, blob_column FROM blob_content WHERE id = 2";
myOracleDataReader = myOracleCommand.ExecuteReader();
myOracleDataReader.Read();
Console.WriteLine("myOracleDataReadre[\"id\"] = " + myOracleDataReader["id"]);
OracleBlob myOracleBlob = myOracleDataReader.GetOracleBlobForUpdate(1);
Console.WriteLine("OracleBlob = " + myOracleBlob.Length);
myOracleBlob.Erase();
FileStream fs = new FileStream(agreement_filename.Text, FileMode.Open, FileAccess.Read);
Console.WriteLine("Opened " + agreement_filename.Text + " for reading");
int numBytesRead;
byte[] byteArray = new byte[fs.Length];
numBytesRead = fs.Read(byteArray, 0, (Int32)fs.Length);
Console.WriteLine(numBytesRead + " read from file");
myOracleBlob.Write(byteArray, 0, byteArray.Length);
Console.WriteLine(byteArray.Length + " written to blob object");
Console.WriteLine("Blob Length = " + myOracleBlob.Length);
fs.Close();
myOracleDataReader.Close();
myOracleConnection.Close();
This gives the following console output:
myOracleDataReadre["id"] = 2
OracleBlob = 0
Opened D:\sample_files\oly_in.doc for reading
56832 read from file
56832 written to blob object
Blob Length = 56832
My write to file code is:
private void save_agreement_to_disk_Click(object sender, EventArgs e)
string filename;
SaveFileDialog savedoc = new SaveFileDialog();
if (savedoc.ShowDialog() == DialogResult.OK)
filename = savedoc.FileName;
// create an OracleConnection object to connect to the
// database and open the connection
OracleConnection myOracleConnection = new OracleConnection("User ID=royalty;Password=royalty");
myOracleConnection.Open();
// create an OracleCommand object to hold a SQL statement
OracleCommand myOracleCommand = myOracleConnection.CreateCommand();
myOracleCommand.CommandText =
"SELECT id, blob_column " +
"FROM blob_content " +
"WHERE id = 2";
OracleDataReader myOracleDataReader = myOracleCommand.ExecuteReader();
myOracleDataReader.Read();
Console.WriteLine("myOracleDataReader[id] = " + myOracleDataReader["id"]);
//Step 2: Get the LOB locator
OracleBlob myOracleBlob = myOracleDataReader.GetOracleBlobForUpdate(1);
Console.WriteLine("Blob size = " + myOracleBlob.Length);
//Step 3: get the BLOB data using the read() method
byte[] byteArray = new byte[500];
int numBytesRead;
int totalBytes = 0;
FileStream fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write);
while ((numBytesRead = myOracleBlob.Read(byteArray, 0, 500)) > 0)
totalBytes += numBytesRead;
fs.Write(byteArray, 0, byteArray.Length);
Console.WriteLine("numBytes = " + numBytesRead + " totalBytes = " + totalBytes);
Console.WriteLine((int)fs.Length + " bytes written to file");
fs.Close();
myOracleDataReader.Close();
myOracleConnection.Close();
This gives the following console output:
myOracleDataReader[id] = 2
Blob size = 0
0 bytes written to file
If I manually add the blob file using the following:
DECLARE
my_blob BLOB;
BEGIN
-- load the BLOB
my_bfile := BFILENAME('SAMPLE_FILES_DIR', 'binaryContent.doc');
SELECT blob_column
INTO my_blob
FROM blob_content
WHERE id = 1 FOR UPDATE;
DBMS_LOB.FILEOPEN(my_bfile, dbms_lob.file_readonly);
DBMS_LOB.LOADFROMFILE(my_blob, my_bfile, DBMS_LOB.GETLENGTH(my_bfile), 1, 1);
DBMS_LOB.FILECLOSEALL();
COMMIT;
END;
COMMIT;
The write to file works perfectly. This tells me that there must be something wrong with my code that is writing the blob to the database. I tried where possible to following the Oracle article using large objects in .NET but that (along with most things on the internet) focus on uploading text files.
Thanks in advance.
Chris.myOracleCommand.CommandText = "insert into blob_content(id, blob_column) values 2, empty_blob())";
OracleDataReader myOracleDataReader = myOracleCommand.ExecuteReader();
This looks wrong, you shouldn't be using ExecuteReader unless you expect to get a result back. Try using ExecuteNonQuery to do the insert. -
can i read binary format file with java? if so, can you please suggest which class i should be looking into?
ThanksFileInputStream
-
How to read a binary file written in LabVIEW 6.1 using VB ?
How to read a file saved in binay forrmat in LabVIEW 6.1 platform through VB.
Is there any code ?
ThanksHello,
LabVIEW files stored in binary can take on just about any format that
you choose, so there will not be a single piece of code that will give
you what you are looking for. You can use VB's standard file
operation functions to read in a binary file created by LabVIEW, just
as you would read in any other binary file. See this page
on Microsoft's web site for more information on the binary file read
operation. How you stored the data in the binary file will
determine how you need to extract it from the byte array. So, if
the first element stored in the file was a 32-bit integer, you could
extract an int from the byte stream to recover that piece of your
data. You would need to know in advance how the file was
formatted in order to successfully retrieve the information. If
you need a reference for the VB functions, the microsoft link above
will get you to some good information.
Cheers,
Matt Pollock
National Instruments -
Convert Large Binary File to Large ASCI File
Hello, I need some suggestions on how to convert a large binary file > 200MB to an ASCI File. I have a program that streams data to disk in binary format and now I would like to either add to my application or create a new app if necessary. Here is what I want to do:
Open the Binary File
Read a portion of the File into an array
Convert the array to ASCI
Save the array to a file
Go back and read more binary data
Convert the array to ASCI
Append the array to the ASCI file
Keep converting until the end of the binary file.
I should say that the binary data is 32-bits and I do need to parse the data; bits 0-11, bits 12-23, and bits 31-28, but I can figure that out later. The problem I see is that the file will be very large, perhaps even greater than 1GB and I don't have a clue how to read a portion of the file and come back and read another portion and then stop at the end of the file. I hope to save the data in a spreadsheet. If anyone has some experience with a similiar situation I'd appreciate any input or example code.
Thanks,
joesle,
In the future, please create a new thread for unrelated questions. To answer your question, you can use "Split Number" from the Data Manipulation palette.
Message Edited by jasonhill on 03-14-2006 03:46 PM
Attachments:
split number.PNG 2 KB -
Hiii
I have developed one Binary file Read/Write Vi.. and then i have convert that vi in to DLL......
Now i tested that DLL Vi it is showing an error No 74. Actually for Binary write i will convert the Input cluster to Flattern to String and for Binary Read i will convert the output to unflattern to string.. I have attached the TEST.vi for reference
Attachments:
Binary Read#Write DLL.vi 18 KB
Binary File Read#Write.vi 24 KB
TEST.vi.vi 31 KBhi there
if you want to read the size of the string you have to enable the "append array or string size" at the write file function. or you do not append the size and simply read all bytes.
in any case you should replace existing files to avoid remaining bytes of larger strings written in prior calls.
See attachment for details.
Best regards
chris
CL(A)Dly bending G-Force with LabVIEW
famous last words: "oh my god, it is full of stars!"
Attachments:
IO.JPG 66 KB
IO_8.5.vi 27 KB -
Fast processing of mixed representation binary files
Hi Everyone,
I see multiple ways of tackling this but I'm looking for the fastest approach as my data set is very large....
The issue:
I have a binary data file holding 2D data.
It encodes 200+ differnet "columns" that are repeated in time (sampled)
The data contains mixed data representaitons: a mxiture of U8, I8, U16, I16 etc.
They are all regullarly repeated in a known file structure (660 bytes per "line")
I'd like to gnereate the 200+ differnet 1-D arrays form the file each using the correct data representaiton (or a sub-set of the columns).
I can load the file in using binary file read and I specify U8 as the data type . I can then rediension to the correct 2D array.
I'm now stuck on the fastest method to process the columns of data (1-2 bytes wide) into the corect numeric representaiton 1-D arrays (2x U8 to i16 etc.).
Scanning byte by byte would be very slow.
any suggesitons?
Solved!
Go to Solution.Taking wrote:
Your sequence structures are unnecessary.
I'd bet on Join Number being faster than any string functions.
What sort of mechanism are you going to use for column definitions?
Do you care if 8 bit datatypes get upcast to 16 bit?
Agreed, the sequence structures only present to aid illustration.
I'm not sure flatten to string is a "true" (slow) string function. I'm viewing it more as a container of bytes. I'm going to run some speed tests. The array massaging that has to go on to use the join function may be a large overhead.
Column definitions will be sourced from a secondary text file that describes the file structure. The example conversion of 2 x u8 to i16 would be replaced by a for loop (over all columns of 1-N bytes) and case structure (representation of the column) that processes the data. Ultimately each 1D array of correctly converted data will be saved off to it's own binary data file in a appropriate numeric representation within the case statement.
Next I will be looking what for loop paralization I can achieve vs. source array memory copies. (again it is a very big source data file). -
Follow/read a growing binary file
Hello,
Application space:
1 - I have an application that has created and opened a binary file, and is is writing data to it
on a continual basis.
2 - Using another program written in Labview, I need to open this file for reading, get all the data available
(for the given file size at that instant) and update a strip chart/graph. The program also needs
to continue to follow that growing file and update the chart as new data is written to it by the
process (other program) that owns it.
Problem space:
If the file is already a certain size when the LV program opens it for reading, it needs to read in that
in it's entirety and update the chart with the complete data set as quick as possible. Then, it needs
to continue to check the file about every 250ms for new data and update the chart if there is new data.
So....How can I initially read in the file and update the chart as fast as possible, then use a controlled loop
rate of 250ms to continue to read in that same file if there is new data?
Suggestions...anyone? An algorithm? A rough diagram? alms for the blind? ;~)
Gary.try to read the file readonly.
Otherwise LabVIEW could block the writing or not succeed in opening the file.
And try reading the filesize and read again when data is available.
greetings from the Netherlands
Maybe you are looking for
-
Revert to 8.1.0 wildly unsuccessful - what next?
I upgraded to Acrobat version 8.2 when the reminder came up (big mistake) - this version contains a bug that adds a pair of characters in front of the odd page footer. (The bug has not been fixed by Adobe, and you can read the sad story of it here: h
-
Issue with Loading Multiple Videos within a Project
I am assembling a Captivate project that needs to include several videos that a quite large. When the entire project is written as a Windows executable projector file, the player does not open because the operating system cannot allocate enough memor
-
Flat File upload into Planning Book
Hi all, I want to upload the data into the Planning Book through "Upload Data" in Interactive Demand Planning. While saving data it is saving perfectly in .CSV file. While i made some changes in the Csv file and i have tried to load the data again in
-
I am trying to apply a Solaris 10 upgrade release to my E450 server, but get the following error during the install process: "Could not reinitialize system state, please exit installer and try again" Retrying the upgrade gives the same error. The cur
-
Hi, Oracle corporations has plans to incorporate new components? If answer is if, As and when? Thanks.