Subtracting numbers in two different txt files

Click For Summary
To subtract numbers from two .txt files and save the results in a new file, several methods are suggested. Users can utilize OpenOffice or LibreOffice as alternatives to Excel. A Python script is recommended for those familiar with programming, allowing for efficient file manipulation. For Windows users, VBScript can be employed to read the files into arrays, perform the subtraction, and write the results back to a new .txt file. Additionally, Google Docs offers a spreadsheet application that can be used online for similar tasks. Providing specific details about the operating system and available tools can help in receiving tailored solutions.
Arjani
Messages
20
Reaction score
1
I have two .txt files with a bunch of numbers in them, below each other, like this:

File 1:

3
4
5

File 2:

1
2
1


Now I want to subtract the numbers in file 2 from the numbers in file 1 and get the results in a new .txt file:

File 3:

2
2
4

Very simple. I was going to do it in Excel, but I don't have that right now. Does anyone know another easy way?
 
Computer science news on Phys.org
Use OpenOffice then. Or write Python script. Or post your problem giving enough information about OS and tools available to get a meaningful answer.
 
If you've got Windows, try VBScript. Read the 2 files into an array, add the elements of the arrays and write the results back out. Here's a link showing how to read and write files: http://easyprograming.com/index.php/vb-script/13-open-an-existing-text-file-in-vb-script
 
Last edited by a moderator:
You could download Open or Libre Office, or sign up for a GMail account and use the spreadsheet Google Docs application.
 
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...

Similar threads

Replies
10
Views
2K
  • · Replies 35 ·
2
Replies
35
Views
5K
Replies
4
Views
2K
Replies
7
Views
3K
Replies
15
Views
9K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
3K
  • · Replies 16 ·
Replies
16
Views
8K
  • · Replies 4 ·
Replies
4
Views
1K