Subtracting numbers in two different txt files

Click For Summary

Discussion Overview

The discussion revolves around methods for subtracting numbers from two different text files and outputting the results to a new text file. Participants explore various software and scripting options for performing this task without using Excel.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant describes the problem of subtracting numbers from two text files and seeks alternative solutions to Excel.
  • Another participant suggests using OpenOffice or writing a Python script, emphasizing the need for more information about the user's operating system and available tools.
  • A different participant recommends using VBScript for Windows users, mentioning how to read files into an array and perform the subtraction.
  • Another option proposed is to download Open or Libre Office, or to use Google Docs' spreadsheet application if the user has a GMail account.

Areas of Agreement / Disagreement

Participants present multiple competing views on how to approach the problem, with no consensus on a single preferred method.

Contextual Notes

The discussion lacks specific details about the user's operating system and programming experience, which may influence the applicability of the suggested solutions.

Who May Find This Useful

Individuals looking for alternatives to Excel for basic arithmetic operations on data stored in text files, particularly those interested in scripting or using different office software.

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.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
Replies
10
Views
3K
  • · Replies 35 ·
2
Replies
35
Views
6K
Replies
4
Views
2K
Replies
7
Views
3K
Replies
15
Views
11K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 31 ·
2
Replies
31
Views
3K
  • · Replies 16 ·
Replies
16
Views
8K