Coder Social home page Coder Social logo

lei_to_bods's Introduction

LEI to BODS conversion

Work in progress, use with caution

A basic python library to convert GLEIF data on company identity and ownership onto BODS v0.2 statements. Detailed documentation yet to be developed.

Usage

All functions are contained in the file lei_to_bods.py. Some example data are provided in the sample_data folder.

To run the functions, clone this repo, navigate to the directory, and run:

import lei_to_bods as lb

Read in a GLEIF submission

LEI data consist of three main data types: level 1 statements about entities, level 2 statements about ownership relationships, and level 2 data on reporting exceptions. See the sample_data folder for example statements of each.

To read in any of these statements and return a python list with one string per statement, use the following:

# level 1 data
lei = lb.read_lei('sample_data/20220705-gleif-concatenated-file-lei2-sample.xml')

#level 2 relationship data
rr = lb.read_lei('sample_data/20220705-gleif-concatenated-file-rr-sample.xml')

#level 2 exception data
repex = lb.read_lei('sample_data/20220705-gleif-concatenated-file-repex-sample.xml')

Convert a single statement

LEI level 1 statement

View a single LEI level 1 statement in original xml format:

print(lei[0])

Convert to a BODS JSON entity statement

entityStatement = lb.lei1_to_entity_statement(lei[0])
print(entityStatement)

LEI level 2 relationship statement

View a single LEI level 2 relationship statement in original xml format:

print(rr[0])

Convert to a BODS JSON ownership or control statement

oocStatement = lb.lei2_relationship_to_ooc_statement(rr[0])
print(oocStatement)

LEI level 2 exception statement

View a single LEI level 2 exception statement in original xml format:

print(repex[0])

Convert to a BODS JSON ownership or control statement with unknown interested party

oocExceptionStatement = lb.lei2_exception_to_ooc_statement(repex[0])
print(oocExceptionStatement)

Convert an entire declaration

If you have a set of LEI statements in a file that represent a single declaration (i.e. a set of relationship statements combined with all connected LEI level 1 statements), you can convert directly to a BODS array as follows:

lb.lei_statement_to_bods('sample_data/20220705-gleif-concatenated-file-statement-sample.xml', write = True, outfile = 'sample_data/20220705-gleif-concatenated-file-statement-sample.json')

You can view this file in the sample_data folder and check using the BODS data review tool, and visualise using the BODS visualiser

Field mappings

Can be found in the file mappings.md

lei_to_bods's People

Contributors

lgs85 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.