You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

32 lines
734 B

#!/usr/bin/env python3
from pandas import read_csv
from pprint import pprint
df = read_csv("./csv/1.csv")
cols = [
('chemical_db_id', 1),
('library', 2),
('name', 4),
('formula', 5),
('mass', 6),
('pubchem_cid', 7),
('pubmed_refcount', 8),
('standard_class', 9),
('inchikey', 11),
('inchikey14', 12),
('final_mz', 15),
('final_rt', 16),
('final_adduct', 17),
('adduct', 18),
('detected_adducts', 20),
('adduct_calc_mz', 21),
('msms_detected', 24),
('msms_purity', 26)
]
idxs = [x[1] for x in cols]
data = [{x[0]: row[x[1]] for x in cols} for row in df.to_dict('tight')['data']]
for x in data:
if x['msms_detected'] == 'No':
del x['msms_detected']