This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
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.

25 lines
551 B

  1. from lark import Transformer
  2. class CsvTreeToPandasDict(Transformer):
  3. INT = int
  4. FLOAT = float
  5. SIGNED_FLOAT = float
  6. WORD = str
  7. NON_SEPARATOR_STRING = str
  8. def row(self, children):
  9. return children
  10. def start(self, children):
  11. data = {}
  12. header = children[0].children
  13. for heading in header:
  14. data[heading] = []
  15. for row in children[1:]:
  16. for i, element in enumerate(row):
  17. data[header[i]].append(element)
  18. return data