-2

Five lines are correct :

GO                                 #Fixed 
EXEC sys.sp_cdc_enable_table       #Fixed
@source_schema = N'RWAW3',         #Fixed
@source_name=N'TUY1                #Variable 
@role_name = NTEDULL               #Fixed

I have 300 codes, 100 of which are missing some fixed lines My program recognizes lines that contain variable values, and I want to combine them with fixed lines 300 times

mylines = []
fname = input("Enter file name: ")
with open (fname) as myfile:
    for myline in myfile:
        mylines.append(myline)
l1 = mylines[0]
l2 = mylines[1]
l3 = mylines[2]
l4 = mylines[3]
l5 = mylines[4]
tl1 = mylines.count(l1)
tl2 = mylines.count(l2)
tl3 = mylines.count(l3)
tl4 = mylines.count(l4)
tl5 = mylines.count(l5)
print(l1.strip () ,  tl1)
print(l2.strip () ,  tl2)
print(l3.strip () ,  tl3)
print(l4.strip () ,  tl4)
print(l5.strip () ,  tl5)
al = len(mylines) 
t = [tl1,tl2,tl3,tl4,tl5]
t.remove(1)
cn= min(t) 
cocm = max(t) 
cncm = cocm - cn 
tl = cn * 5
print('\nMissing lines:' , cncm)
print('Salting, Go to code:' , tl)

lst = list()
for line in fh:
    word= line.rstrip().split()
    for element in word:
        if element in lst:
            continue
        else :
            lst.append(element)

Required 1- :

cocm=312
print(l1\n,l2\n,l3\n,lst[0}\n,l5)

Repeated 312 (cocm) times As the value in the lst() changes in ascending order

Required 2-:

tl4 = mylines.count(l4)
print(tl4)
>>> 1

The program recognized the line l4 as a variable so it added in the lst() menu I want to know the position when printing

majed
  • 1
  • 5
  • 2
    You"re question is not clear enough to understand what you want to do. Your code doen't connect with your request. It's unclear why you posted the code at all. Please update and give more examples if you want people to help you. – user2853437 Jun 12 '20 at 12:33
  • My code for analyzing the document data to see the changing line that will be the number of iterations = one and to know the most frequent constant line to see how many lines of data are supposed to be I have finished analyzing the document and want to implement and print the amendment based on the analysis data – majed Jun 12 '20 at 14:03
  • 1
    Without some example data it is really hard to help, may you edit your post and add this information. I'm sure your problem can then be solved quickly: try to structure it like this: 1) example input 2) code (already there) 3) expected output of script 4) current result – user2853437 Jun 12 '20 at 14:20
  • I modified my question Thanks for your interaction – majed Jun 12 '20 at 19:58
  • Can you please [edit] the question to clarify what you are asking of us? What is the code supposed to do and in how far does this not satisfy your requirements? What specific technical problem do you need help with? – MisterMiyagi Jun 12 '20 at 20:04
  • Exceeded four lines Print(lst.[0]) Exceeded four lines Print(lst[1]) . . Complete 1500 lines in the same pattern – majed Jun 12 '20 at 20:57
  • Sorry, I'm having trouble to understand that. What do you mean by "Exceeded four lines Print(lst.[0])"? Do you mean "whenever four lines are read (accumulated? merged?), print the next element of ``lst``"? Can you perhaps provide a *short* sample input and desired output for that sample? – MisterMiyagi Jun 13 '20 at 08:06
  • I modified my question Thanks for your interaction . – majed Jun 13 '20 at 17:40

1 Answers1

0

I got an answer

mylines = []
mmm=[]
fname = input("Enter file name: ")
#with open (fname) as myfile:
myfile =  open (fname)
for myline in myfile:
        mylines.append(myline)
        if myline in mmm :
             continue
        else:
             mmm.append(myline)
mm=mmm[5:]
l1 = mylines[0]
l2 = mylines[1]
l3 = mylines[2]
l4 = mylines[3]
l5 = mylines[4]
tl1 = mylines.count(l1)
tl2 = mylines.count(l2)
tl3 = mylines.count(l3)
tl4 = mylines.count(l4)
tl5 = mylines.count(l5)
print(l1,l2,l3,l4,l5.strip ())
x = len(mm)
while x > 0 :
    if tl1 == 1  : print(mm[0].strip ())
    else : print(l1.strip ())
    if tl2 == 1 : print(mm[0].strip ())
    else : print(l2.strip ())
    if tl3 == 1 : print(mm[0].strip ())
    else : print(l3.strip ())
    if tl4 == 1 : print(mm[0].strip ())
    else: print(l4.strip ())
    if tl5 == 1 : print(mm[0].strip ())
    else : print(l5.strip ())
    del mm[0]
    x = x-1
else:
 quit()
majed
  • 1
  • 5