LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy every other line

Solved!
Go to solution

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!

0 Kudos
Message 1 of 13
(4,463 Views)

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 

0 Kudos
Message 2 of 13
(4,459 Views)

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

0 Kudos
Message 3 of 13
(4,458 Views)

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.

0 Kudos
Message 4 of 13
(4,438 Views)

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)

Message Edited by altenbach on 10-07-2008 08:39 AM
Message 5 of 13
(4,432 Views)

... 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.)

Message Edited by altenbach on 10-07-2008 09:02 AM
0 Kudos
Message 6 of 13
(4,422 Views)

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!!

0 Kudos
Message 7 of 13
(4,410 Views)
What's your LabVIEW version?
0 Kudos
Message 8 of 13
(4,405 Views)

8.5

 

Thanks

0 Kudos
Message 9 of 13
(4,403 Views)
Solution
Accepted by sjberg
Try this. Modify as needed. 🙂
Message 10 of 13
(4,397 Views)