I am trying to set a path for directory to read all .txt or .csv files inside of it from jupyter notebook on windows. My initial code was:
import pandas as pd
import numpy as np
import matplotlib as plt
import sys
import ntpath
import glob, os
# creating list of all .txt in folder
path=r'C:\Users\User\Documents\Scripts on ML_DL_AI_PHM\data'
myfile=glob.glob('*.txt')
all_files = glob.glob(os.path.join(path, "*.txt"))
and it works perfectly fine in spyder.
But, jupyter throw an error message on the cell with setting path variable:
File "<ipython-input-40-2bd796a8736c>", line 1
path = 'C:\Users\User\Documents\Scripts on ML_DL_AI_PHM\data'
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Asking for help from experienced jupyter users...