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.

33 lines
745 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/2.csv")
  5. pprint(list(enumerate(df.columns)))
  6. cols = [
  7. ('chemical_db_id', 1),
  8. ('library', 2),
  9. ('name', 4),
  10. ('formula', 6),
  11. ('mass', 7),
  12. ('pubchem_cid', 10),
  13. ('pubmed_refcount', 8),
  14. ('standard_class', 11),
  15. ('inchikey', 13),
  16. ('inchikey14', 14),
  17. ('final_mz', 17),
  18. ('final_rt', 18),
  19. ('final_adduct', 19),
  20. ('adduct', 20),
  21. ('detected_adducts', 22),
  22. ('adduct_calc_mz', 23),
  23. ('msms_detected', 26),
  24. ('msms_purity', 28)
  25. ]
  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']