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://") \
     .config("spark.mongodb.output.uri", "mongodb://") \

df = = '/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 in Python by Ahmed
• 310 points
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 in Python by Karan
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 in Python by Nymeria
• 3,520 points
0 votes
1 answer
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,720 points
0 votes
2 answers

how to print the current time using python?

print( READ MORE

answered Feb 14 in Python by Shashank
• 1,350 points
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 399 views