Could you kindly review this request… the attached script and see what can be wrong?. Or review it please?.
Thanks a lot
Hello @Dada
What is the issue? I have tried the https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python code part and it returns data successfully on my end.
import lseg.data as ld ld.open_session() grain_ships = ld.content.pricing.chain.Definition(name="GRAIN/SHP/FR").get_stream() grain_ships.open(False) field_list = [f"ROW80_{i + 1}" for i in range(25)] ship_streams = ld.content.pricing.Definition( universe=grain_ships.constituents, fields=field_list ).get_stream() ship_streams.open(False) # open stream in snapshot mode for item in grain_ships.constituents: print(item) for i, field in enumerate(field_list): row_value = ship_streams[item][field] print(row_value)
It seems that support guy who gave you the code did not handle the None value returns from the API.
The client should feedback to that support guy to review code.
Alternatively, the code can apply the following logic to handle the None value:
for item in grain_ships.constituents: # iterates on each GRAIN/SHP/FR row start = False for i, field in enumerate(field_list): row_value = ship_streams[item][field] # get row string valueif row_value and PORT_PATTERN.match(row_value.strip()): # detect "--- PORT ---" current_port = row_value.strip().strip("-").strip() port.append(current_port) data_list[current_port] = [] if first_item: titles = ship_streams[item][field_list[i - 1]].split() first_item = False start = True continue if not start: continue # Split row_value with expected format data = [row_value[start:end].strip() for start, end in zip(indices, indices[1:])] if data[0] and data[-1]: # test if SHIP and DAY are not empty data_list[current_port].append(data)