Discussion:
Combining data files
(too old to reply)
magreent
2008-08-13 14:40:09 UTC
Permalink
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
MikeS81
2008-08-13 15:10:08 UTC
Permalink
Hi Magreen,read your files and merge it with one of the others. Use the file IO visMike
craigc
2008-08-13 15:10:09 UTC
Permalink
Hi This is one method for doing it with text files.&nbsp;<img src="Loading Image..." 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
magreent
2008-08-13 15:40:08 UTC
Permalink
Thanks for replying.I can't seem to find the component just after path,(The yellow one with a picture of glasses:) what is this component? is it in Labview 7?
Mathur
2008-08-13 15:40:09 UTC
Permalink
yeah it is on Block Diag window, in functions, programing , File I/O, Read text file.
MikeS81
2008-08-13 18:40:06 UTC
Permalink
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
2008-08-15 16:10:08 UTC
Permalink
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:
Loading Image...


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
2008-08-15 17:40:31 UTC
Permalink
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="Loading Image..." 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
magreent
2008-08-15 18:10:07 UTC
Permalink
Thanks,&nbsp;Is it possible that you email this as a vi. file.I cannot locate some of the tools you have used.&nbsp;
altenbach
2008-08-15 18:10:08 UTC
Permalink
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
Continue reading on narkive:
Loading...