Workspace API using LSEG Data Library does not show any result

Options

Trying to pull data by Worksapce API (LSEG Data Libarry, desktop session) returns "Company Common Name", instead of "Toyota Motor Corp" by

rics = ['7203.T']
fields = ['TR.CommonName']
df, err = ld.get_data(universe=rics, fields=fields)

lseg-data version is 2.1.1

python code, log file and result screenshot is as attached.

Please advise what is wroing.

Answers

  • Hi @Midori ,

    The result of get_data function of the Data Library only yield one DataFrame of result (unlike Eikon Data API, which yield the Dataframe and Error message, if any)

    Hence, assigning result into 2 variables causes the error

    image.png

    This is the example when assign output to one variable, then print it

    image.png

    This is the example code that works.

    # get_data_desktop.py
    import lseg.data as ld
    import pandas as pd

    def main():
    try:
    print("Connecting to LSEG Workspace desktop application...")
    ld.open_session()
    print("Session opened successfully.")

    print("\nAttempting data request...")
    rics = ['7203.T']
    fields = ['TR.CommonName'] # 企業名のフィールド
    df = ld.get_data(universe=rics, fields=fields)

    if df is not None:
    display(df)
    else:
    print("No data returned.")

    except Exception as e:
    print(e)

    finally:
    if 'ld' in globals() and hasattr(ld, 'close_session'):
    print("\nClosing API session.")
    ld.close_session()

    if __name__ == "__main__":
    main()