I have written a script that imports existing data from a .csv file, modifies it, plots it, and also asks the user for an input (input2) that is used as the graph title and filename for the data set and graph. I would like to have another script (import.py) that executes the original script (new_file.py) and is able to determine what the user's input was so that I can access the newly-created files. How can I pass the user input from one script to the other?
The script that takes the user input is new_file.py:
def create_graph():
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
input1 = input("Enter the file you want to import: ")
data_file = pd.read_excel(input1 + ".xlsx")
ws = np.array(data_file)
a = ws[:, 0]
b = ws[:, 1]
c = ws[:, 2]
bc = b + c
my_data1 = np.vstack((a, b, c, bc))
my_data1 = my_data1.T
input2 = input("Enter the name for new graph: ")
np.savetxt(input2 + ".csv", my_data1, delimiter=',')
plt.plot(a, b, 'ro')
plt.plot(a, c, 'go')
plt.plot(a, bc, 'bo')
plt.ylabel("y-axis")
plt.xlabel("x-axis")
plt.legend(['Column 1 data', 'Column 2 data', 'Column 3 data'], loc='best')
plt.title(input2)
plt.savefig(input2)
plt.show()
The second script (import.py) that I am trying to use to run this is currently:
import new_file as nf
nf.create_graph()
I'm not sure how to pass input2 from new_file.py to import.py. Can anyone help me please? Thank you