Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

how to transfer values from one big text file to another

hello,

I dont know where to place this question, but any ideas will be greatly apprecciated.
im having two text files- lets say A and B
A is having values like this
1 0 0 1
2 0 1 1
3 0 0 -4
4 0 0 -4

and B is having values like

1…1.4910967E+003  8.7261375E+002  1.1463431E+003  -3.0539021E+002  1.9476335E+002   -3.5904820E+002
2……………...

so what i want is to bring the values from A into B where last number is less than zero, in the above example they are 3 and 4th rows. So i want to bring in the 3 and 4 into the B file.


the problem is i cannot import it into excel as the file has more than 65000 rows and also matlab cannot do this function.

can somebody tell me how i could achieve this....

I need only the correspording rows from the A file, and the chosed rows should build a new table, if possible in turn, with the original sequence. The A file has only a function, to help us to decide which row  be useful in the second file
0
vihar123
Asked:
vihar123
2 Solutions
 
girionisCommented:
If I understand correctly you will need a raf: http://javaalmanac.com/egs/java.io/UseRandomAccessFile.html
0
 
CodingExpertsCommented:
I sugest you to use StreamTokenizer to operate on this algo.


http://www.codeguru.com/java/tij/tij0113.shtml

-CE
0
 
OrtokoboldCommented:
Have you ever used script languages, like awk or perl?
It would be ideal solution for your problem. You just need a simple script to read file A, filter-out the lines you need, and print them. Get yourself an awk or perl interpreter, and ask this question in the perl channel.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
vihar123Author Commented:
are there any free tools that can do this, i dont want to program, and is it possible with excel to do this......as the task is just getting those minus values into an other txt file, i dont want to write a new prg as it will not be of any use later

actually these values are retreived through matlab and these files are quite big, more than 70,000 rows......so i really dont know if i can do it with excel.....or other tools
0
 
MogalManicCommented:
Looks like you will have to write a program it looks like Excel is limited to 65535 rows.

Using programs, the # of rows would not matter, because a program can be written to just process 1 line at a time.  Here is how I would do it in Awk and other UNIX type utils:
ProcessA.awk (1 line file)
$NF<0 {print $0}

To run:
awk -f ProcessA.awk  A.txt > tmpA.txt
cat  B.txt tmpA.txt>newB.txt

Now 'newB.txt' will contain B+all of the rows from A where the last field is < 0
0
 
MogalManicCommented:
If you don't have access to Unix, you can download GAWK, cat (and other unix utils) at http://unxutils.sourceforge.net/
0
 
vihar123Author Commented:
i havent used it but ill accept this answer

thanks :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now