플랫 파일에 열을 추가하는 함수를 만들고 있습니다. 지금까지 내가 가진 : 그러나파일 끝에 행의 끝에 쓰기
(defun ff-from-vector (vec dir file)
(with-open-file (ff-vec-str (make-pathname :name file
:directory dir)
:direction :output
:if-exists :overwrite)
(dotimes (i (length vec))
(format ff-vec-str "~A~%" (svref vec i)))))
(defun vec-from-1col-ff (dir file)
(let ((col (make-array `(,(ff-rows dir file)))))
(with-open-file (ff-col-str (make-pathname :name file
:directory dir)
:direction :input)
(do ((line (read-line ff-col-str nil 'eof)
(read-line ff-col-str nil 'eof))
(i 0 (incf i)))
((eql line 'eof))
(setf (aref col i) (read-from-string line))))
col))
(defun add-col-to-ff (col-dir col-file ff-dir ff-file)
(ff-from-vector (vec-from-1col-ff col-dir col-file)
ff-dir
ff-file))
, 나는 파일에서 읽을 때 :
2
2
2
2
그리고 파일 덮어 쓰기를 시도 :
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
를 내가 얻을 :
2
2
2
2
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
기본적으로 내 질문은 : what function or code mo 출력 파일의 줄 끝에 서식을 지정 하시겠습니까? 그래야 내가 얻을 수 있습니다 :
1 1 1 1 2
1 1 1 1 2
1 1 1 1 2
1 1 1 1 2
텍스트 편집기를 사용하여 자동 들여 쓰기를 사용해야합니다. 위의 코드는 수동으로 들여 쓰여진 것처럼 보이지만 혼란 스럽습니다. –