How to save the import csv file to mongodb using pyspark (or python)?

0 votes

I have this code, and I want to save the import csv file to mongodb using pyspark but I have 43 error if there another way :

from pyspark.sql import SparkSession
my_spark = SparkSession \
     .builder \
     .appName("myApp") \
     .config("spark.mongodb.input.uri", "mongodb://127.0.0.1/testtt.coll") \
     .config("spark.mongodb.output.uri", "mongodb://127.0.0.1/testtt.coll") \
     .getOrCreate()

df = spark.read.csv(path = '/home/user/Desktop/testtt.csv', header=True, inferSchema=True)



 my problem with is code:
 
df.write.format("com.mongodb.spark.sql.DefaultSource").mode("append").option("database","testtt").option("collection", "coll").save()
Oct 9, 2019 in Python by Ahmed
• 310 points
486 views
Hey @Ahmed!

It is difficult to find the problem without the error log. Please share the error log.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

How to import json file to mongodb using pyspark (or python)?

You can use the same format as ...READ MORE

answered Sep 9, 2019 in Python by Karan
303 views
0 votes
1 answer

How to use read a WSDL file from the file system using Python suds?

Hi, good question. It is a very simple ...READ MORE

answered Jan 21, 2019 in Python by Nymeria
• 3,540 points
1,317 views
0 votes
1 answer

How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

answered May 20, 2019 in Python by Sanam
113 views
0 votes
1 answer
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,760 points
3,629 views
0 votes
2 answers

how to print the current time using python?

print(datetime.datetime.today()) READ MORE

answered Feb 14, 2019 in Python by Shashank
• 1,370 points
85 views
+2 votes
1 answer
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 760 views