Commit 8ca6a67a authored by Micaël Bergeron's avatar Micaël Bergeron

add the json loader

parent d2168b66
import json
import pandas as pd
from itertools import count
from meltano.load.base import MeltanoLoader
from meltano.common.service import MeltanoService
from meltano.common.entity import Entity
class JSONLoader(MeltanoLoader):
def __init__(self, *args):
self.filenames = dict()
def filename(self, basename):
Generates a sequential filename for a basename.
<basename> → <basename>.<seq>.json
if basename not in self.filenames:
self.filenames[basename] = (
".".join((basename, "{:04}".format(i), "json")) \
for i in count()
return next(self.filenames[basename])
def load(self, entity: Entity, data):
data.to_json(self.filename(entity.alias), orient='records')
MeltanoService.register_loader("com.meltano.load.json", JSONLoader)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment