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.

27 lines
592 B

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