LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Multiple files from one txt file

  I have an issue.  I thought this was going tobe a very quick and easy thing todo but it is turning more and more into a headache.  One of my programs generates txt files that are around 40 MB.  I would like to take these files and break them into 10-15 MB sections. Basically split the txt file into smaller txt file. 

 

    1st approach:

               I tried using the "Read From Measurement File" to read the larger .txt I then tried to rewrite the data into a series of new txt files with the

               "Write to txt file" function,  with doing this I thought I would be able to control the size of the new files.  When I go into the properties of the

               "Write to txt file" function I select "Save to multiple files" then set the limit on the txt file size.  Yea...seems to easy it dosn't work for me.

 

    2nd approach:

             I am using the "Read from measurement File" to read the larger txt file.  I then conert the data to a 2D array.  Now I am wondering if there is

             anyway I can splice up this 2D array and write it to a series of txt files.

 

 

V/r,

Chris

0 Kudos
Message 1 of 3
(2,590 Views)

Hello,

 

A couple thoughts come to mind:

 

  • Directly to your question
    You can certainly slice up your 2D array and write it to multiple text files - just use the array subset function, perhaps in a loop, to take chunks and generate a series of files.  Perhaps use the loop index variable to help you name the series of files.

  • What about storing the data in TDMS?
    If you want/need the files to be human readable, then ASCII is great as you have done.  However, I'm wondering if you'd have an easier time storing/managing the data in a binary format.  For example, you could use TDMS files which, if you're writing/streaming lots of data will have some inherent benefits.  I won't articulate all the potential benefits here, but checkout documentation on TDMS for details.  I will note that LabVIEW ships with a nice little TDMS viewer VI which can be used to inspect your data, and subsets thereof, in graphical and numerical form.

  • What about writing a series of files as the data comes in?
    I actually replied to another post about this recently: How to avoid one single large TDMS file?
    Perhaps have a look there and see if something like that might help you get the series of files you want as you acquire the data vs having to post-process your single big file.  The general idea presented there will apply equally well to other files types, so don't be deterred by the TDMS detail there.

Hope this helps!

 

Best,
JLS
Sixclear
0 Kudos
Message 2 of 3
(2,573 Views)
0 Kudos
Message 3 of 3
(2,551 Views)