There are plenty of examples on the site... search and learn!
(defun c:PolylineProp (/ *error* file ss ent i)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
(princ (strcat "\nError: " errmsg)))
(if file (close file))
(princ))
(if (and (setq ss (ssget '((0 . "LWPOLYLINE"))))
(setq file (open (strcat (getvar 'DWGPREFIX) "PolylineProp.csv") "a"))
(princ (strcat "Filepath: "(strcat (getvar 'DWGPREFIX) "PolylineProp.csv")))
(write-line "" file)
)
(repeat (setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i))))
(setq txt (strcat (cdr (assoc 8 (entget ent))) ","
(rtos (getpropertyvalue ent "Length")) ","
(rtos (getpropertyvalue ent "Area")) ","
(cdr (assoc 5 (entget ent)))))
(write-line txt file)
(princ (strcat "\n" txt))))
(princ)
)