Jared Garvin-Joseph
02/06/2024, 12:10 AMparse_response
in client.py
def parse_response(self, response: requests.Response) -> Iterable[dict]:
"""Parse the response and return an iterator of result records.
Args:
response: The HTTP ``requests.Response`` object.
Yields:
Each record from the source.
"""
# TODO: Parse response body and return a set of records.
# print(response.json())
keys = [column['name'] for column in response.json()['columnDefinitions']]
combined_data = []
for data_row in response.json()['data']:
if len(keys) != len(data_row):
raise ValueError('Mismatch between keys and values length')
combined_data.append(dict(zip(keys, data_row)))
print('data_data@@@', json.dumps(combined_data))
json_data = json.dumps(combined_data)
yield from extract_jsonpath('$[1]', input=json_data)
And im 100% sure the yield is a valid json. Im getting this error from jsonl
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Which is leading me to believe that whatever im yielding is not getting to the target. Am I handling the response in the correct place? Do I need a get_records
or something in my streams.py so the proper message gets passed to my target?william chaplin
02/06/2024, 12:51 AMwilliam chaplin
02/06/2024, 12:53 AMEdgar Ramírez (Arch.dev)
02/06/2024, 1:08 AMprint
call or do print(..., file=sys.stderr)
. Singer taps use on stdout to pass data to the target 🙂.Jared Garvin-Joseph
02/06/2024, 7:04 PMJared Garvin-Joseph
02/07/2024, 12:59 AMcombined_data = []
for data_row in response.json()['data']:
if len(keys) != len(data_row):
raise ValueError('Mismatch between keys and values length')
combined_data.append(dict(zip(keys, data_row)))
print('data_data@@@', json.dumps(combined_data))
json_data = json.dumps(combined_data)
yield from extract_jsonpath('$[1]', input=combined_data)
Jared Garvin-Joseph
02/07/2024, 12:59 AMcombined_data
is a list of json objects (that are valid)Jared Garvin-Joseph
02/07/2024, 1:00 AMparse_response
yield go directly to the loader?Edgar Ramírez (Arch.dev)
02/07/2024, 3:07 PMmeltano invoke <my-tap> > my-tap.singer.jsonl
and inspect the contents of that file to see if there's any offending line. I'm curious, what target are you using?Jared Garvin-Joseph
02/07/2024, 8:08 PMtarget-jsonl
Jared Garvin-Joseph
02/07/2024, 8:08 PMEdgar Ramírez (Arch.dev)
02/07/2024, 8:52 PMmeltano invoke
suggestion above. Watch out for lines that are not valid json objects.Jared Garvin-Joseph
02/07/2024, 9:15 PMEdgar Ramírez (Arch.dev)
02/07/2024, 9:15 PMJared Garvin-Joseph
02/07/2024, 9:24 PMJared Garvin-Joseph
02/07/2024, 9:25 PM