How to import data (pipe delimited) to JSON database using python to POST API? | Coursera Community

How to import data (pipe delimited) to JSON database using python to POST API?

  • 2 March 2021
  • 0 replies
  • 11 views

Badge +1

I have a file that is data.txt, in this file it contains data with the format FirstName | LastName | Email. example:
John]Swen]john@gmail.com
ricard]candra]ricard@gmail.com

So, how do I get the contents of the data.txt into the Json file using python? url = http://localhost:3000/db.json. I have db.json which I will input data using the POST API, in the db.json which already contains data:
[
{
      "id": 1,
      "first_name": "Sebastian",
      "last_name": "Eschweiler",
      "email": "sebastian@codingthesmartway.com"
    },
    {
      "id": 2,
      "first_name": "Steve",
      "last_name": "Palmer",
      "email": "steve@codingthesmartway.com"
    }
]

expected output after POST API:
[
{
      "id": 1,
      "first_name": "Sebastian",
      "last_name": "Eschweiler",
      "email": "sebastian@codingthesmartway.com"
    },
    {
      "id": 2,
      "first_name": "Steve",
      "last_name": "Palmer",
      "email": "steve@codingthesmartway.com"
    },
    {
      "id": 3,
      "first_name": "John",
      "last_name": "Swen",
      "email": "john@gmail.com"
    },
   {
      "id": 4,
      "first_name": "ricard",
      "last_name": "candra",
      "email": "ricard@gmail.com"
    }
]


0 replies

Be the first to reply!

Reply