Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Loading a file
- filename = input("Please enter .csv filename: ")
- path = os.listdir(os.getcwd())
- #*If the file is in the path, the code will run*
- if filename in path[:len(path)]:
- print("nData has been loaded!n")
- loadcsv = pd.read_csv(filename, header = None, names = cols)
- cols = ['StudentID', 'Name']
- if (loadcsv.iloc[0] != cols).all():
- print("The uploaded file is not valid")
- break
- else:
- print("nFile has not been found.")
- #File upload gets reset if not found in listdir.
- loadcsv = np.array([])
- filename = input("Please enter .csv filename: ")
- path = os.listdir(os.getcwd())
- #*If the file is in the path, the code will run*
- if filename in path[:len(path)]:
- print("nData has been loaded!n")
- loadcsv = pd.read_csv(filename)
- cols = ['StudentID', 'Name']
- for c in loadcsv.columns:
- if c not in cols:
- print("The uploaded file is not valid")
- break
- else:
- print("nFile has not been found.")
Add Comment
Please, Sign In to add comment