11-27-2010 02:36 PM
Hi Guys,
I have a problem in appending data from files in different columns. I have attachement has file A and B which I am reading and not able to get data as in file Result.txt. Please comment on how can I do this
Solved! Go to Solution.
11-27-2010 02:37 PM
Here is the Result.txt file.
11-27-2010 03:05 PM
You have to append the data from all files before doing a single write.
11-27-2010 05:11 PM - edited 11-27-2010 05:12 PM
You cannot append columns to an existing file. Since the data is arrange line-by-line as one long linear string in the file, you can only append rows. A new row needs to be interlaced into the original file, shifting everything else. If you want to append rows, you need to build the entire output structure in memory and then write all at once.
(I also don't think you need to set the file positions, it will be remembered from the last write operation.)
Unless the files are gigantic, here's what I would do:
(Also note that some of your rows have an extra tab at the end. If this is normal, you need a little bit more code to strop out empty columns. I include cleaned up files in the attachment. I also would not call them A.txt.txt etc. A plain A.txt is probably sufficient.)
EDIT: It seems Dennis's solution is similar ;))
11-27-2010 05:54 PM
The file would be gigantic. Wount this VI work for n number of files with a couple of hundred MB each.
11-28-2010 12:31 AM
You'll probably run out of memory trying to do all in one swoop.
I assume that all files have the same size, so just read a good chunk (= same number of lines) of each file, merge, write, read the next chunks, append, etc. For this you might want to go back to low level file IO.
See how far you get. 🙂