Stack Overflow Asked by Ömer Can on November 26, 2020
Here is my first file’s codes:
from csv import writer
film=[""] #The list contains informations about the film
#İnputs:
filmname=input("Film name: ")
category=input("category: ")
score=input("point: ")
score=str(score)
complement=input("complement: ")
valuablenames=input("İmportant actors: ")
#Appending Inputs
film.append(filmname)
film.append(category)
film.append(score)
film.append(complement)
film.append(valuablenames)
#The Function which appends the list into csv file:
def liste_append(filename,inf_list):
with open("FilmSet.csv", 'a+', newline='') as write_obj: # Open file in append mode
csv_writer = writer(write_obj) # Create a writer object from csv module
csv_writer.writerow(film) # Add contents of list as last row in the csv file
#Calling Function
liste_append("FilmSet.csv",film)
#Jumping to File which converts csv to xlsx
#Jumping to File which converts csv to xlsx
The part i need your help to close this file and jump to the other one (which is a converter program and named as "converter.py").So when i run this program,it will update the csv file and jump to "converter.py" for updating excel file from csv converted.( deletes the old xlsx and creates new xlsx which is converted from csv )
My recommendation would be to turn one of the python files into a package and simply import the required functions.
So in this case put your csv conversion from conversion.py
into a function like csv_to_xlsx()
and then from conversion import csv_to_xlsx()
and then run it at the end of your main file.
You could use the subprocess
module with subprocess.Popen() or os.system(). These will allow you to execute python code from another file. Also the worst other solution is exec()
this allows you to pass python code as a string and execute it. so you could do
exec(open('file.py', 'r').read())
Correct answer by Kieran Wood on November 26, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP