
A Regulatory Analysis Dashboard for Fast Searching NITE CHRIP Data using FTS5
NITE CHRIP Data Conversion Regulatory data provided by the Chemical Substance Risk Information Platform (CHRIP) is published in XML format. In this project, we designed a process to convert this data to CSV format and then import it into FTS5. import xml.etree.ElementTree as ET import pandas as pd def xml_to_csv ( xml_path , output_csv ): tree = ET . parse ( xml_path ) root = tree . getroot () records = [] for item in root . findall ( ' item ' ): record = { ' cas_number ' : item . find ( ' cas_number ' ). text if item . find ( ' cas_number ' ) is not None else '' , ' substance_name ' : item . find ( ' substance_name ' ). text if item . find ( ' substance_name ' ) is not None else '' , ' regulation_id ' : item . find ( ' regulation_id ' ). text if item . find ( ' regulation_id ' ) is not None else '' , ' regulation_text ' : item . find ( ' regulation_text ' ). text if item . find ( ' regulation_text ' ) is not None else '' } records . append ( record ) df = pd . DataFrame ( records ) df
Continue reading on Dev.to Python
Opens in a new tab

