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

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