Python Forum
Combining 2 or more scripts to one.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combining 2 or more scripts to one.
#1
Hi,

Id like to know how i can make one script from 2 or more so i can just run one script with multiple functions.
Below are the 2 scripts which i want to have running in one script.
Both scripts have their own output file and time of execution.



import time
import schedule    
#starttime=time.time()
  
def task():  
  
#Input_file: "C:\\Campbellsci\\LoggerNet\\CR1000_Table1.dat"
#Output_file: "C:\\Users\\Makada\\Desktop\\CR1000_Table1 - kopie.dat"
  
 while True:
    """ Not to append duplicate data to output file"""
    existingLines = set(line.strip() for line in open("C:\\Users\\Makada\\Desktop\\CR1000_Table1 - kopie .dat"))
    outfile = open("C:\\Users\\Makada\\Desktop\\CR1000_Table1 - kopie .dat", "a+")
    for content in open("C:\\Campbellsci\\LoggerNet\\CR1000_Table1.dat", "r"):
        if content.strip() not in existingLines: # to void duplicate lines
            outfile.write(content)
            existingLines.add(content)
    outfile.close()
  
schedule.every().minute.at(":01").do(task)
while True:
    schedule.run_pending()
    time.sleep(1)
refresh()
import time
import schedule    
#starttime=time.time()
  
def task():  
  
#Input_file: "C:\\Campbellsci\\LoggerNet\\CR1000_Table1.dat"
#Output_file: "C:\\Users\\Makada\\Desktop\\CR1000_Table1 - kopie.dat"
  
 while True:
    """ Not to append duplicate data to output file"""
    existingLines = set(line.strip() for line in open("C:\\Users\\Makada\\Desktop\\CR1000_Table2 - kopie.dat"))
    outfile = open("C:\\Users\\Makada\\Desktop\\CR1000_Table2 - kopie.dat", "a+")
    for content in open("C:\\Campbellsci\\LoggerNet\\CR1000_Table2.dat", "r"):
        if content.strip() not in existingLines: # to void duplicate lines
            outfile.write(content)
            existingLines.add(content)
    outfile.close()
  
schedule.every().minute.at(":10").do(task)
while True:
    schedule.run_pending()
    time.sleep(1)
refresh()
Reply


Messages In This Thread
Combining 2 or more scripts to one. - by Makada - Mar-29-2020, 08:47 PM
RE: Combining 2 or more scripts to one. - by Makada - Mar-30-2020, 05:16 AM
RE: Combining 2 or more scripts to one. - by Makada - Mar-30-2020, 08:20 AM
RE: Combining 2 or more scripts to one. - by Makada - Mar-30-2020, 04:28 PM
RE: Combining 2 or more scripts to one. - by Makada - Mar-31-2020, 10:34 AM
RE: Combining 2 or more scripts to one. - by Makada - Apr-01-2020, 05:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  interloper help appreciated combining two python3 scripts to add new conditions. Ricktoddfrank 0 1,477 Jun-22-2021, 10:24 PM
Last Post: Ricktoddfrank

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020