Pass CSV File as Parameter to Web Service

1.3k Views Asked by At

How to pass CSV file contents as parameter to web service in python.Now i am passing only 5 values to web service and inserting it to mongodb database. I am using soaplib web service and mongodb database,using soaplib load data to database. How to pass CSV file contents to web service and insert it to mongodb database?

Thanks

1

There are 1 best solutions below

0
On

Try out the following steps:

  1. Firstly locate the CSV file location, which is programmatically accessible from your Python. Consider it as path
  2. Go through this link, read the file similar to the example quoted in the linked article.

    Example:

    fo = open(path + "yourfile.csv", "r+")
    str = fo.read(10);     
    
  3. Open Connection to MongoDB with your mongo-python-driver

    Example:

    import pymongo
    client = pymongo.MongoClient("localhost", 27017)
    
  4. Then ultimately pass the content of the file, which you read in step

    Example: db.my_collection.save({"CSV_FileContent": Obj_CSV_File})

To pass your file content from your python program to a web service, you may try following: