(setq #List
'(
("cable01" "M1" "E1")
("cable02" "M1" "E2")
("cable03" "M1" "E3")
("cable04" "E1" "M4")
("cable05" "E2" "M5")
("cable06" "E2" "M1")
))
(defun TestAssoc (KeyVal DatLst / AscLst)
(foreach ForElm DatLst
(setq AscLst (cons (cons (cadr ForElm) (car ForElm)) (cons (cons (caddr ForElm) (car ForElm)) AscLst)))
)
(Cdrs KeyVal AscLst)
)
; Orginal by M. Puckett > Cdrs
(defun Cdrs (DxfKey ImpLst / TmpLst OutLst)
(while (setq TmpLst (assoc DxfKey ImpLst))
(setq OutLst (cons (cdr TmpLst) OutLst)
ImpLst (cdr (member TmpLst ImpLst))
)
)
(reverse OutLst)
)
(TestAssoc "E1" #List) =>("cable04" "cable01")
(TestAssoc "M1" #List) =>("cable06" "cable03" "cable02" "cable01")
How are you currently getting the data results ? Post code ?I imported from an Excel worksheet using http://www.lee-mac.com/readcsv.html
What result did you expect in the samples you have shown ?
Is the data format consistantly shaped ??I did not get this point
Maybe rebuild the list is one option:
...
Maybe something like this?Thanks for your help but gives error
; error: bad argument type: consp "HVT-16-0120"
Thanks Grrr1337Code - Auto/Visual Lisp: [Select]
)
Another -Working perfectCode - Auto/Visual Lisp: [Select]