Print a python script down a list in a text file without printing a lot combinations
In a python script I have 2 files printing side by side on the same line. I want to have 1 of the files to be already displayed at once while the other file print down the list in the file and it still will produce new lines. I want to do it like that to reduce printing a lot of lines and combinations.
Code:
from itertools import izip_longest
with open("file1") as textfile1, open("file2") as textfile2:
for x, y in izip_longest(textfile1, textfile2, fillvalue=""):
x = x.strip()
y = y.strip()
print("{0}{1}".format(x, y))
This is what the script does now:
aaaaaa 111111
bbbbbb 222222
cccccc 333333 Both lines move and still print
the same lines every time.
dddddd 444444
eeeeee 555555
gggggg 666666
What I desire the script to do:
This file2 is
about to go
through file1
111111 This will print first in the order of the file
222222 second
333333 third
444444 fourth
555555 fifth
666666 This will print last in the order of the file
↓↓
This file1
is already
loaded or
displayed
at once
not moving
at all
aaaaaa
bbbbbb As file2 goes down file1, each line
should hit every line creating a new
cccccc combination until the list has completely
went through.
dddddd
eeeeee
gggggg
file2 is done going
through file1
111111
222222
333333
444444
555555
666666
Code:
111111 should hit aaaaaa first,
then when 111111 will hit bbbbbb,
222222 should be on aaaaaa,
then when 111111 hit cccccc,
2222222 should be on bbbbbb,
then 333333 should be on aaaaaa, then so on and so on.
The list should go down the other list in a trail line until completely.
Example of output
Code:
Example of output or what I should see in terminal
aaaaaa
bbbbbb 666666
cccccc 555555
dddddd 444444
eeeeee 333333 Each line is trailing down the list
gggggg 222222
111111
Last edited by bigvito19; 09-02-2019 at 04:48 PM..
Hello,
I am not sure whether this is the right forum or not, if not sorry for that.
I am trying to print text at desire column with python script.
eg. in this sentence
print >>AA_sql, "Hello"+ "World"
I want to print "Hello" at column10 and "World" at column30, simple idea is to... (2 Replies)
Dear all, could you please help me with awk please?
I have such input:
Input:
a d
b e
c f
The number of lines is unknown before reading the file.
I need to print possible combination between the two columns like this:
Output:
a d
b d
c d
a e
b e
c e
a f (2 Replies)
Hello All!!
Long time since i haven't been here, but here is my new question.
I love giving myself challenges. Here is the new one:
in the european euro-million, you choose 5 from 50 numbers plus 2 from from 9 "stars" (9 numbers).
So in fact, you have the possibility to have 76275360... (4 Replies)
I have a text file with a list of items/patterns:
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig12238
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig34624... (1 Reply)
I have 2 text files:
cities.txt
San Francisco
Los Angeles
Seattle
Dallas
master.txt
Atlanta is chill and laid-back.
I love Los Angeles.
Coming to Dallas was the right choice.
New York is so busy!
San Francisco is fun.
Moving to Boston soon!
Go to Seattle in the summer.
... (0 Replies)
Hi Friends,
I have a series of alphabets like this
AGCAA
The values inside the square brace indicate that either of them can be present at that position. And those ones without a brace, means that they are the only ones that could be printed at that location.
Now, I would like to know... (5 Replies)
I'm working on a new exercise that calls for a script that will take in two arguments on the command line (representing the range of line numbers) and will subsequently print those lines from a a specified file. Command line would look like this: ./lines_script.bash 5 15 <file.txt. The script would... (8 Replies)
Hello.
First happy new year to everybody.
I have a script that generate a text file ( /tmp/part_list.txt for example ).
This file can be edited using a kde graphical text editor like kate or kwrite
The file can be printed out from command line or within the text editor using the print... (5 Replies)
hi all,
trying this using shell/bash with sed/awk/grep
I have two files, one containing one column, the other containing multiple columns (comma delimited).
file1.txt
abc12345
def12345
ghi54321
...
file2.txt
abc1,text1,texta
abc,text2,textb
def123,text3,textc
gh,text4,textd... (6 Replies)