Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Combining data files

0 views
Skip to first unread message

magreent

unread,
Aug 13, 2008, 10:40:09 AM8/13/08
to
Hi, I tooks data from hardware and saved it as a series of small files so I would not be stuck with huge files. Now I want to put together some of these files. I have the files as data_001.lvm, data_002.lvm, data_003.lvm etc. I have tried using the merge files option but it put the data side by side. I want this data to be output in the same columns so that I have  a column with all the time data and a column with all the sampled amplitudes. I have attached 2 exapmles of the data files. I am using Labview 7.0.  Thanks, Magreen


data_001.txt:
http://forums.ni.com/ni/attachments/ni/170/348983/1/data_001.txt


data_002.txt:
http://forums.ni.com/ni/attachments/ni/170/348983/2/data_002.txt

craigc

unread,
Aug 13, 2008, 11:10:09 AM8/13/08
to
Hi This is one method for doing it with text files.&nbsp;<img src="http://forums.ni.com/ni/attachments/ni/170/348992/1/Files.png" border="0" width="465" height="194">&nbsp; &nbsp;&nbsp;To expand on this concept you could put the operation in a for loop with an array of filenames as the IP. and a shift register to keep appending each file.CraigMessage Edited by craigc on 08-13-2008 09:47 AM


Files.png:
http://forums.ni.com/ni/attachments/ni/170/348992/1/Files.png

MikeS81

unread,
Aug 13, 2008, 2:40:06 PM8/13/08
to
Hi Magreen,
you can also use the &quot;Seek&quot; function. If you use it you only need to read one file. Open the other file, move the &quot;cursor&quot; to the end of file position and write the read data to this file. If you do you don&acute;t need to read all data into memory.&nbsp;Hope it helps.Mike&nbsp;

magreent

unread,
Aug 15, 2008, 12:10:08 PM8/15/08
to
I managed to combine the files using the attached files. Now I need help using a loop to combine a large number of files. In this example I combine only 3&nbsp; files. In reality, I would need to do this for maye 100 files.


FileOpen.png:
http://forums.ni.com/ni/attachments/ni/170/349649/1/FileOpen.png


FileOpen7.vi:
http://forums.ni.com/ni/attachments/ni/170/349649/2/FileOpen7.vi


data_001.txt:
http://forums.ni.com/ni/attachments/ni/170/349649/3/data_001.txt

altenbach

unread,
Aug 15, 2008, 1:40:31 PM8/15/08
to
May file tools have changed, but you definitely don't want to read it as numerics, sice your files are already formatted.&nbsp;Read your files as a plain text string in a loop and append the string to a new file until you run out of files. Here's a quick draft that you need to adapt to LabVIEW 7.0.&nbsp;<img src="http://forums.ni.com/ni/attachments/ni/170/349670/1/CombineFiles.png" border="0"> Message Edited by altenbach on 08-15-2008 10:27 AM


CombineFiles.png:
http://forums.ni.com/ni/attachments/ni/170/349670/1/CombineFiles.png

altenbach

unread,
Aug 15, 2008, 2:10:08 PM8/15/08
to
As I said, the file IO has changed quite a bit since LabVIEW 7.0. Since my VI is in LabVIEW 8.5, you won't be able to open it.&nbsp;Still you should be able to create it from scratch.&nbsp;- Create a while loop
- define the folder containing your file (e.g. using&nbsp; the file dialog or a diagram constant).
- Open a new file for the output.
- In the loop, create the file names according to the format pattern
- If the file does not exist (e.g. &quot;file info&quot; generates an error), do nothing and stop the loop
- if the file exists, read as a plain text string and append it to the new file.
- Repeat until you run out of matching files.
- Close the new file.
&nbsp;(You could also use &quot;list files&quot; with e.g. &quot;data_*.txt&quot; as pattern and simply autoindex over the file names in a FOR loop.)&nbsp;See how far you get. If you think you are close, attach your work and we find out what else is needed. ;)Message Edited by altenbach on 08-15-2008 11:00 AM
0 new messages