python - Input file doesn't exist even though the file is mentioned in the correct location- pyspark -


i'm trying read log lines forming key-value pairs error. code:

logline=sc.textfile("c:\testlogs\testing.log").cache()  lines = logline.flatmap(lambda x: x.split('\n')) rx = "(\\s+)=(\\s+)"  line_collect = lines.collect()  line in line_collect :       d = dict([(x,y) x,y in re.findall(rx,line)])         d = str(d)       print d 

error:

line_collect = lines.collect()......invalidinputexception: input path not exist: file:/c:/testlogs esting.log

i don't know how correct this. i'm new python , spark.

try replace logline=sc.textfile("c:\testlogs\testing.log").cache() logline=sc.textfile("c:\\testlogs\\testing.log").cache()

the backslash character not '\' in string rather "\\"


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -