test2.py 572 B

12345678910111213141516171819202122
  1. def printsection(b):
  2. print(b)
  3. obj = dict(zip(b[::2], b[1::2]))
  4. for keys, values in obj.items():
  5. if keys == '1':
  6. print(values)
  7. print("\n")
  8. #if obj.get('1'):
  9. # print('{}'.format(obj['1']))
  10. buffer = []
  11. file = open("GV_12.DXF", "r")
  12. for line in file:
  13. line = line.strip()
  14. #print(line)
  15. if line == '100': # we've started a new section, so
  16. printsection(buffer) # handle the captured section
  17. buffer = [] # and start a new one
  18. buffer.append(line)
  19. printsection(buffer)