0

I have the folowing txt file:

COL1 COL2 Col3 1 2 3 4 5 6 7 8 9

And onother txt file:

COL1
11
44
77

What I want to do is to repalce the first column of the first txt file, with the first column of the second column.

Is there a fast way to do that using java, or I have to replace line by line?

Yacino
  • 645
  • 2
  • 10
  • 32
  • 1
    You need to open the file. Read it in line by line. Replace the column you want replaced and then write out the new changed line to a new file. When you are done you can delete the original file but I wouldn't do that until you are sure the change was made correctly. – mba12 Apr 26 '17 at 15:23
  • 1
    yep its line by line, but if time is what you are worried about, this process can be done in less than a sec for 1M lines or so. – nafas Apr 26 '17 at 15:23
  • Yes I have been thinking to do that, but I want to know if there is a simple and fast way to do that, because I have to read a voluminous txt file. – Yacino Apr 26 '17 at 15:25
  • @nafas thanks for the information, I think that's it, there no other way. – Yacino Apr 26 '17 at 15:27
  • For ways to do this without writing a new program, see also the answers in [Rearrange columns using cut](http://stackoverflow.com/questions/2129123/rearrange-columns-using-cut). – Andy Thomas Apr 26 '17 at 15:28
  • @AndyThomas Thanks, I need to do it using java. – Yacino Apr 26 '17 at 15:31

0 Answers0