Guest User

Untitled

a guest
Jan 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #Loading a file
  2. filename = input("Please enter .csv filename: ")
  3. path = os.listdir(os.getcwd())
  4.  
  5. #*If the file is in the path, the code will run*
  6. if filename in path[:len(path)]:
  7. print("nData has been loaded!n")
  8. loadcsv = pd.read_csv(filename, header = None, names = cols)
  9. cols = ['StudentID', 'Name']
  10. if (loadcsv.iloc[0] != cols).all():
  11. print("The uploaded file is not valid")
  12. break
  13. else:
  14. print("nFile has not been found.")
  15. #File upload gets reset if not found in listdir.
  16. loadcsv = np.array([])
  17.  
  18. filename = input("Please enter .csv filename: ")
  19. path = os.listdir(os.getcwd())
  20.  
  21. #*If the file is in the path, the code will run*
  22. if filename in path[:len(path)]:
  23. print("nData has been loaded!n")
  24. loadcsv = pd.read_csv(filename)
  25. cols = ['StudentID', 'Name']
  26.  
  27. for c in loadcsv.columns:
  28. if c not in cols:
  29. print("The uploaded file is not valid")
  30. break
  31. else:
  32. print("nFile has not been found.")
Add Comment
Please, Sign In to add comment