I have 2 text files (big files over 1gb) that opens side by side on the same line in terminal, but I want the file on the right to print down the other file while the file on the left is stationary or displayed all at once. I want to print text file 2 through all of text file 1.
from itertools import izip
with open("textfile1") as textfile1, open("textfile2") as textfile2:
for x, y in izip(textfile1, textfile2):
x = x.strip()
y = y.strip()
print("{0}{0}".format(x, y))
What it does now:
paste -d ' ' a b
1 a
2 b
3 c
4 d
5 e
6
7
8
9
Desired output:
1 ↓
2 a
3 b
4 c
5 d
6 e
7
8
9
1
2
3 ↓
4 a
5 b
6 c
7 d
8 e
9
Re-looping
1 b
2 c
3 d
4 e
5
6
7 ↓
8 List is about to loop
9 a
If your input files are over a 1Gb, which we might assume means that there are millions of lines in each file, are you saying that you want to produce quadrillions of lines of output? Why in the world would you want to do that?
I'm not trying to go that route and produce many lines like that. Lets say I have a python script that could load and run a file over 1GB like the script I have at the top and I have another text file that's 1GB also. Is there a way I could pipe hex the python script to the text file and print the python script against the text file and get combinations but without producing quadrillions of lines. Using the text file as a place holder for lines.
You say you aren't trying to go that route, but that is exactly what your "desired output" and your "re-looping" show in post #1 in this thread.
I don't know what "pipe hex the python script to the text file" means.
I don't know what "print the python script against the text file" means.
By definition a text file contains a sequence of zero or more lines of text. I don't know what "Using the text file as a place holder for lines." means.
Please explain clearly in English what you are trying to do and show us (small) sample input files and the exact output you hope to produce.
Note that if you want all of the combinations of millions of lines (109) from one file with millions of lines (109) from another file you are talking about quadrillions of combinations (109 * 109 = 10**18) (i.e., quadrillions of lines of output).
This is the pipe hex example
example.py | file1./another program will be here
Example of output
example.py | file1
generating | aaa
lines | bbb
↓ | ccc
printing against | ddd
the text file | eee
I only see the two files printed side by side. I do not see any other combinations of either input file in your desired output.
I'm obviously not contributing anything here, so I'll be quiet and hope someone else can figure out what you're trying to do and will be able to help you. I apologize for any confusion I have caused.