Solution: CSV to JSON with custom fields (Python 3.7)

Development | Programming languages
Price

Price: 50.00 € (for solution)

Money-Back Guarantee
Description
Parse CSV file containing host info to JSON usable with custom fields.

Preview code:
#!/usr/bin/python
from json import dumps
from os import access, R_OK
from os.path import exists
from argparse import ArgumentParser
import datetime
FIELDS = {'AIX': ['env', 'appGroup', 'host', 'ip', 'clusterType', 'startAt', 'enabledAt', 'defaultCluster'],
          'LINUX': ['env', 'appGroup', 'host', 'ip', 'commType', 'startAt', 'enabledAt'],
          'ORACLE': ['env', 'appGroup', 'host', 'startAt', 'enabledAt'],
          'WINDOWS': ['env', 'appGroup', 'host', 'ip', 'commType', 'startAt', 'enabledAt']
          }

Preview input:
ENV;GROUP;host;IP;cluster-type;start-at;enable-at;default-cluster
PERF;WLS;sk06wls00a;10.212.206.19;standalone;;;
PERF;WLS;sk06wls00b;10.212.206.147;standalone;;;
PERF;WLS;sk06wls01v;10.212.206.20;standalone;;;sk06wls01v

Preview output:
{
  "data": [
    {
      "env": "PERF",
      "appGroup": "WLS",
      "host": "sk06wls00a",
      "ip": "10.212.206.19",
      "clusterType": "standalone",
      "startAt": "2019-02-01T22:04:17.997524",
      "enabledAt": "2019-02-01T22:04:17.997524",
      "defaultCluster": "",
      "update": true
    },
    {
      "env": "PERF",
      "appGroup": "WLS",
      "host": "sk06wls00b",
      "ip": "10.212.206.147",
      "clusterType": "standalone",
      "startAt": "2019-02-01T22:04:17.997524",
      "enabledAt": "2019-02-01T22:04:17.997524",
      "defaultCluster": "",
      "update": true
    },
    {
      "env": "PERF",
      "appGroup": "WLS",
      "host": "sk06wls01v",
      "ip": "10.212.206.20",
      "clusterType": "standalone",
      "startAt": "2019-02-01T22:04:17.997524",
      "enabledAt": "2019-02-01T22:04:17.997524",
      "defaultCluster": "sk06wls01v",
      "update": true
    }
  ]
}
Attachments
No attachments.
Solutions
You must purchase this solution to view the solution.
What masters said
You need to purchase this solution to comment on the solution.
All comments
This solution has not been commented yet.
We use cookies to give you the best possible experience on our site. By continuing to use the site you agree to our use of cookies. Find out more Accept