LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saving text files based on size

Hello,

 

With my program, I am trying to save text files from labview onto the computer based on size. EG: if a text file exceeds say 10 Mb then the remaining data is saved on a new text file and so on. So in the end a 100 Mb data file gets saved as 10 text files of 10 Mb each.

I tried doing something using while loops but did not work. I ended up getting a bigger file. Could anyone provide some inputs into this.

 

Thank You

 

0 Kudos
Message 1 of 5
(2,288 Views)

I think this will help you

0 Kudos
Message 2 of 5
(2,270 Views)

Hey,

Tnx for the suggestion...but I am unable to implement it into my diagram.
Can there be some possibility with For Loops??

0 Kudos
Message 3 of 5
(2,232 Views)

Your code has several issues, some of which will make it simply not work.  Going from left to right on the diagram:

 

  1. Your first FOR loop assumes all the attributes in the file are strings.  If this is true, you are good.  If not, you will get an empty string instead of the item you expect.  This comment holds for the leftmost FOR loop inside the right FOR loop, as well.  If this is a problem, you have two options.  You can either hard code the conversion based on the attribute name or you can detect the data type of the variant using the VIs in <vi.lib>\Utility\VariantDataType and switch your conversion based on this information.
  2. Only data in the last group will make it into your file.  The output tunnel from parsing the data is a simple tunnel, so will only give you the data from the last group.  If you want data from all the groups, you will need to run a shift register to concatenate the data from different groups.
  3. The right-most loop reads all the data from the file and converts it to a string in memory.  If you are dealing with 100MByte data sets, you have a high probability of running out of memory unless you are using 64-bit LabVIEW.  I would suggest you read and convert your data in chunks.  This will also allow you to split your file easily, since you can detect, at the end of each chunk, how large the file is and start a new one, if needed.
  4. Your text file breaks the tab-separated-text coding convention.  You use spaces in your header instead of tabs for separators.  For your attributes, you use a colon and space instead of a tab.  This will make reading the file into a spreadsheet more difficult.  Using tabs for everything makes reading it into a spreadsheet (e.g. Excel) very easy.
  5. Consider using the tab constant from the string menu.  It makes code much more readable.  You may want to use the end-of-line constant, too.

Issue 3 above, until solved, will make splitting your data into multiple files very difficult.  You can fetch in chunks from a TDMS file by specifying an offset and number of points when you get an array of data.

 

You can keep track of how big your file is by keeping track of the size of the strings you add to it and add them up.  You will need to add a shift register to your loop to do this.

 

If you need more info, please let us know.  You are heading in the right direction.

 

 

 

0 Kudos
Message 4 of 5
(2,219 Views)

Hello DFGray,

 

Thank You for ur reply.

Issues 1 and 2 is no problem for me, as I am getting the correct form of text file in the end. With the names on top followed by the corresponding measurement values. I have implemented the TAB constant as you suggested (yes I had a problem reading in excel) (am wrking with labview for only 4 months now so don't know all the features).

 

I will try implementing the suggestion for breaking the TDMS file so as to get different text files. Will tell you how it goes.

0 Kudos
Message 5 of 5
(2,200 Views)