python - How to write to a csv file on the local file system using PySpark -


i have code writing csv file on local filesystem error - ioerror: [errno 2] no such file or directory: 'file:///folder1/folder2/output.csv'

columns = [0,1,2,3,4,5,6,7,8,9] data1 = rdd1.map(lambda row: [row[i].encode("utf-8") in columns]) data1_tuple = data1.map(tuple)  open("file:///folder1/folder2/output.csv", "w") fw:     writer = csv.writer(fw, delimiter = ';')     (r1, r2) in izip(data1_tuple.tolocaliterator(), labelsandpredictions.tolocaliterator()):         writer.writerow(r1 + r2[1:2]) 

on local filesystem following directory exists - /folder1/folder2/. why throwing error , how can write csv file on local filesytem @ specific directory?

path argument open

either string or bytes object giving pathname (absolute or relative current working directory) of file opened or integer file descriptor of file wrapped

not uri. means code should follows:

with open("/folder1/folder2/output.csv", "w") fw:     writer = csv.writer(fw, delimiter = ';')     ... 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -