10-07-2008 09:47 AM
Hi All,
I have some very large data files that I am working with (50,000 lines) and I wish to cut these down to a more manageable size by copying everyother line or every 5th line to a new file. Perhaps Labview is not the best option for this but so far I have just been beating my head off the wall.
Any suggestions would be appreciated!
Solved! Go to Solution.
10-07-2008 09:53 AM
One approach which comes to mind is to convert the file to an array of strings (one string per line) with the Spreadsheet String to Array function. Then decimate the array. Convert one of the decimated arrays back to a string and save to the new file.
The Decimate function is expandable but not programmable so you would have to choose the decimation factors at programming time, not at run time. You could have a few options selectable via a case structure.
Lynn
10-07-2008 09:54 AM
There is no reason you couldn't do this, but it's not very clear from your message exactly what you want to do. Not just decimating the files, but what exactly are you trying to do with these files. It's not really clear what we are talking about. From the syntax, I'm guessing you are dealing with text files, and that you are counting the number of rows in the text file (50k rows). For one, that isn't really big, unless you have tons of columns as well. Do you have to use text files? They are much less efficient to access and store than binary files. Why decimate? Did you consider breaking the file in half, or in quarters? Are you loading the entire file, or parts?
With a little more information, I'm sure we can get a solution for you.
Chris
10-07-2008 10:25 AM
Sorry for being so breif before.
Basically my file has 56 columns. Column 1 is a time stamp and the rest are signal data from sensors.
My problem is, I wish to work with the data in excel (specifically graph the data). 50K lines is way too much for excel to handle effectively and I will to cut down the data file by removing lines. Whether it be every other line, or 5 lines at a time. Essentially we collected data a 1 second intervals, but for analysis purposes we may only need to look at the data in 5 or 10 second intervals.
Hope this clears things up a bit.
10-07-2008 10:37 AM - edited 10-07-2008 10:39 AM
One simple possibility: Read your datafile as a string, convert to a 1D array of strings, decimate, convert back to a string and write to file.
See image:

(If you want a variable decimation factor, use a simple FOR loop)
10-07-2008 11:00 AM - edited 10-07-2008 11:02 AM
... and if you want to decimate by a variable factor, replace the decimate primitive with e.g. the following simple code:

(For example if the decimation factor is e.g. 3, you'll retain every third element.)
10-07-2008 11:31 AM
Thanks for your help.
Would you be able to post the .vi. I am relatively new to LabView and don't necessarily recognize all of the symbols by looking at them.
Thanks again!!
10-07-2008 11:32 AM
10-07-2008 11:35 AM
8.5
Thanks
10-07-2008 11:43 AM