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
770 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. pprint(list(enumerate(df.columns)))
  6. cols = [
  7. ('chemical_db_id', 1),
  8. ('library', 2),
  9. ('name', 4),
  10. ('formula', 5),
  11. ('mass', 6),
  12. ('pubchem_cid', 7),
  13. ('pubmed_refcount', 8),
  14. ('standard_class', 9),
  15. ('inchikey', 11),
  16. ('inchikey14', 12),
  17. ('final_mz', 15),
  18. ('final_rt', 16),
  19. ('final_adduct', 17),
  20. ('adduct', 18),
  21. ('detected_adducts', 20),
  22. ('adduct_calc_mz', 21),
  23. ('msms_detected', 24),
  24. ('msms_purity', 26)
  25. ]
  26. idxs = [x[1] for x in cols]
  27. data = [{x[0]: row[x[1]] for x in cols} for row in df.to_dict('tight')['data']]
  28. for x in data:
  29. if x['msms_detected'] == 'No':
  30. del x['msms_detected']