fb_pixel

CSV to JSON with custom fields (Python 3.7)

Development | Programming languages
Price
50.00 €
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
Info
You must log in or purchase one of our profile products to access.
All coments
This job has not been commented yet.