(defun C:convert-txt-katalog-to-txt-table (/ clear-list-punkts flag lg-list-katalog list-katalog list-punkts list-punkts-add-separator list-str list-str2 list-str3 n planshet txt-katalog-list txt-katalog-patch list-centr list-znak-klass)
  (if(setq txt-katalog-patch (getfiled "Выбор файла координат" (getvar "DWGPREFIX")  "txt" 0))
    (progn
      (setq txt-katalog-list(file_read_to_list txt-katalog-patch))
      (foreach x txt-katalog-list
	(setq list-katalog (append list-katalog (list (convert-string-to-list-be-delimiter x "\t"))))
	)
      (setq lg-list-katalog(length list-katalog))
      (setq flag T)
      (setq list-punkts (list (list "Планшет" "Номер по каталогу" "Hазвание пункта" "Тип знака" "Класс" "Высота знака" "Тип центра" "Марка" "Высота" "X.1" "Y.1" "X.2" "Y.2" "X.3" "Y.3")))
      (setq n 0)
      (while flag
	(setq list-str (nth n list-katalog))
	(cond
	  ((and (eq (nth 0 list-str) "")(not(eq (nth 1 list-str) ""))(eq (nth 2 list-str) "")(eq (nth 3 list-str) ""))
	   (setq planshet (nth 1 list-str)))
	  ((and (eq (nth 0 list-str) "Номер")(eq (nth 1 list-str) "Hазвание пункта,"))
	   (setq n (+ n 2)))
	  ((and (not(eq (nth 0 list-str) ""))(not(eq (nth 1 list-str) "")))
	   (setq list-str2 (nth (1+ n) list-katalog))
	   (setq list-str3 (nth (+ n 2) list-katalog))
	   (setq list-znak-klass(list (substr (nth 1 list-str2) 1 (-(strlen(nth 1 list-str2))5))
				      (substr (nth 1 list-str2) (-(strlen(nth 1 list-str2))5) )
				      ))
	   (if (not(eq(nth 1 list-str3)""))
	     (setq list-centr(convert-string-to-list-be-delimiter (nth 1 list-str3) "Центр"))
	     (setq list-centr (list "" "")))
	   (setq list-punkts (append list-punkts (list(list planshet
							    (nth 0 list-str);номер
							    (nth 1 list-str);название
							    (vl-string-trim " "(nth 0 list-znak-klass));тип знака
							    (vl-string-trim " "(edit-string-replase-str "" " кл."(nth 1 list-znak-klass)));класс
							    (vl-string-trim " "(edit-string-replase-str "" " м"(nth 0 list-centr)));высота знака
							    (if (nth 1 list-centr)(vl-string-trim " "(nth 1 list-centr))"");тип центра
							    (edit-string-replase-str "" "М "(edit-string-replase-str "" "M "(nth 3 list-str2)));марка или Центр II
							    (vl-string-trim "-"(nth 3 list-str));отметка
							    (if (eq(substr(nth 2 list-str2)1 1)"1")(edit-string-replase-str "" " " (nth 2 list-str))"");X.1
							    (if (eq(substr(nth 2 list-str2)1 1)"1")(edit-string-replase-str "" " " (nth 2 list-str2))"");Y.1
							    (if (eq(substr(nth 2 list-str2)1 1)"2")(edit-string-replase-str "" " " (nth 2 list-str))"");X.2
							    (if (eq(substr(nth 2 list-str2)1 1)"2")(edit-string-replase-str "" " " (nth 2 list-str2))"");Y.2
							    (if (eq(substr(nth 2 list-str2)1 1)"3")(edit-string-replase-str "" " " (nth 2 list-str))"");X.3
							    (if (eq(substr(nth 2 list-str2)1 1)"3")(edit-string-replase-str "" " " (nth 2 list-str2))"");Y.3
							    ))))
	   (setq n (+ n 2))
	   )
	  )
	(setq n (1+ n))
	(if (or (= n lg-list-katalog)(> n lg-list-katalog))(setq flag nil))
	)
      (setq clear-list-punkts (clear-txt-katalog-table list-punkts))
;;;      (setq clear-list-punkts list-punkts)
      (foreach y clear-list-punkts
	(setq list-punkts-add-separator (append list-punkts-add-separator (list(convert-list-to-string-be-delimiter y "\t"))))
	)
      (file_write_list_to_file (strcat (vl-filename-directory txt-katalog-patch) (vl-filename-base txt-katalog-patch) "_"(vl-filename-extension txt-katalog-patch)) list-punkts-add-separator)
      )
    )
  (princ)
  )

(defun clear-txt-katalog-table (input-list / current-punkt current2-punkt flag1 flag2 n nn result-list)
  (setq result-list (list (nth 0 input-list)))
  (setq n 1)
  (setq flag1 T)
  (while flag1
    (name-file-to-messege (itoa n))
    (setq current-punkt (nth n input-list))
    (setq nn (1+ n))
    (if (or (= nn (length input-list))(> nn (length input-list)))(setq flag2 nil)(setq flag2 T))
    (while flag2
      (setq current2-punkt (nth nn input-list))
      (if (and (eq (nth 1 current-punkt)(nth 1 current2-punkt))(eq (nth 2 current-punkt)(nth 2 current2-punkt)))
	(progn
	  (setq current-punkt(combine-punkt-clear-txt-katalog-table current-punkt current2-punkt))
	  (setq input-list (edit-list-del-item-by-number nn input-list))
	  )
	(setq nn (1+ nn))
	)
      (if (or (= nn (length input-list))(> nn (length input-list)))(setq flag2 nil))
      )
    (setq result-list (append result-list (list current-punkt)))
    (setq n (1+ n))
    (if (or (= n (length input-list))(> n (length input-list)))(setq flag1 nil))
    )
  (delete-name-file-to-messege)
  result-list
  )

(defun combine-punkt-clear-txt-katalog-table (punkt1 punkt2 / result n)
  (setq n 0)
  (foreach x punkt1
    (if (and (eq x "")(not(eq (nth n punkt2)"")))
      (setq result (append result (list (nth n punkt2))))
      (setq result (append result (list x))))
    (setq n (1+ n))
    )
  result
  )
;;;(combine-punkt-clear-txt-katalog-table (list "30-26-87" "7" "Забурунный" "дв. пир." "3" "4.5" "1" "" "24,2" "310376,45" "1405441,08" "" "" "" "")(list "30-26-87" "7" "Забурунный" "дв. пир." "3" "4.5" "1" "" "24,2" "" "" "410376,45" "2405441,08" "" ""))
;;;(list "30-26-87" "7" "Забурунный" "дв. пир." "3" "4.5" "1" "" "24,2" "310376,45" "1405441,08" "" "" "" "")

;;;	  (cond
;;;	    ((and(not(eq(nth 9 current-punkt)""))(not(eq(nth 11 current2-punkt)"")))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 11 current2-punkt) 11 (edit-list-del-item-by-number 11 current-punkt)))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 12 current2-punkt) 12 (edit-list-del-item-by-number 12 current-punkt))))
;;;	    ((and(not(eq(nth 9 current-punkt)""))(not(eq(nth 13 current2-punkt)"")))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth



;;;13 current2-punkt) 13 (edit-list-del-item-by-number 13 current-punkt)))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 14 current2-punkt) 14 (edit-list-del-item-by-number 14 current-punkt)))
;;;	     )
;;;	    ((and(not(eq(nth 11 current-punkt)""))(not(eq(nth 9 current2-punkt)"")))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 9 current2-punkt) 9 (edit-list-del-item-by-number 9 current-punkt)))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 10 current2-punkt) 10 (edit-list-del-item-by-number 10 current-punkt)))
;;;	     )
;;;	    ((and(not(eq(nth 11 current-punkt)""))(not(eq(nth 13 current2-punkt)"")))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 13 current2-punkt) 13 (edit-list-del-item-by-number 13 current-punkt)))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 14 current2-punkt) 14 (edit-list-del-item-by-number 14 current-punkt)))
;;;	     )
;;;	    ((and(not(eq(nth 13 current-punkt)""))(not(eq(nth 9 current2-punkt)"")))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 9 current2-punkt) 9 (edit-list-del-item-by-number 9 current-punkt)))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 10 current2-punkt) 10 (edit-list-del-item-by-number 10 current-punkt)))
;;;	     )
;;;	    ((and(not(eq(nth 13 current-punkt)""))(not(eq(nth 11 current2-punkt)"")))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 11 current2-punkt) 11 (edit-list-del-item-by-number 11 current-punkt)))
;;;	     (setq current-punkt (edit-list-add-item-by-number (nth 12 current2-punkt) 12 (edit-list-del-item-by-number 12 current-punkt)))
;;;	     )
;;;	    )
;;;	  (setq input-list (edit-list-add-item-by-number current-punkt n (edit-list-del-item-by-number n input-list)))