i can not understand it can you give me an example for p x y ----> x,y ?something like this
gawk "{print $2 $3 }" input-file.txt > output-file.txt
i can not understand it can you give me an example for p x y ----> x,y ?It would actually be ...
gawk "{print $2\",\" $3 }" data.txt > outputfile.txt
i can not understand it can you give me an example for p x y ----> x,y ?
thanks
318349.74,4231547.73
318445.61,4231568.79
318446.37,4231561.59
318443.36,4231549.82
318438.82,4231539.87
318428.56,4231532.33
318425.25,4231523.57
318428.55,4231513.05
318442.57,4231516.64
318455.87,4231506.94
318473.12,4231495.81
318473.84,4231490.78
318468.81,4231486.11
318468.45,4231473.18
318464.85,4231451.63
318460.90,4231446.96
318447.24,4231446.60
318439.70,4231458.45
318431.79,4231475.34
318424.60,4231475.34
318399.26,4231473.08
318390.21,4231473.39
318382.97,4231477.91
318379.64,4231487.26
318376.02,4231521.35
318372.99,4231537.20
318368.15,4231541.13
318354.88,4231545.65
318349.74,4231547.73
gawk "{print $2\",\" $3 }" 1.txt
318349.74,4231547.73
318445.61,4231568.79
318446.37,4231561.59
318443.36,4231549.82
318438.82,4231539.87
318428.56,4231532.33
318425.25,4231523.57
318428.55,4231513.05
318442.57,4231516.64
318455.87,4231506.94
318473.12,4231495.81
318473.84,4231490.78
318468.81,4231486.11
(defun _TSV->List ( tsvfilename / foo i handle s result )
(defun foo ( s / result )
(while (setq i (vl-string-position 9 s nil t))
(setq
result (cons (substr s (+ 2 i)) result)
s (substr s 1 i)
)
)
(cons s result)
)
(if (setq handle (open tsvfilename "r"))
(progn
(while (setq s (read-line handle))
(setq result (cons (foo s) result))
)
(close handle)
(vl-remove 'nil (reverse result))
)
)
)
(defun _List->CSV ( lst tsvfilename / handle )
(if (setq handle (open tsvfilename "w"))
(progn
(foreach r lst
(princ (car r) handle)
(foreach x (cdr r) (princ "," handle) (princ x handle))
(princ "\n" handle)
)
(null (close handle))
)
)
)
;; read it in
(setq lst (_TSV->List "c:\\docs\\tsv.txt"))
;; abuse it
(setq alt (mapcar (function (lambda (r) (reverse (mapcar 'set '(x y) (cdr r))))) lst))
;; write it out
(_List->CSV alt "c:\\docs\\csv_abused.txt")
(setq result (cons (read (strcat "(" s ")")) result))
I attach a *.txt file with the coordinates.I try fools code but the *.pl file is empty
no fooCode: [Select](setq result (cons (read (strcat "(" s ")")) result))
(SETQ str " 0 318349.74 4231547.73 ")
(read (strcat "(" str ")"))
hI. I am searching for a lisp to convert coordinate files files to x,y (*.txt)
1) p,x,y,z --->x,y
2) p,x,y ---->x,y
3) p x y z ---> x,y
4) p x y ----> x,y
i know that i can do it with excel but i need something faster.
Thanks
to be more in line with the original requirements the translators would need to work successfully on this list.
with the addition of TABS as per the provided file.
to be more in line with the original requirements the translators would need to work successfully on this list.
with the addition of TABS as per the provided file.
0 300000.00 4000000.00 0.0
1 318445.61 4231568.79
2 318446.37,4231561.59,123
3 318443.36,4231549.82
4 318438.82 4231539.87 0.0
5 318428.56, 4231532.33, 0.0
6,318425.25,4231523.57,0.0
7, 318428.55, 4231513.05, 0.0
8 318442.57 4231516.64
9 318455.87 4231506.94
10 318473.12 4231495.81
just saying ...
(defun _Normalize ( str )
(foreach delim '(" " "," "\t")
(foreach pattern (list (strcat " " delim) (strcat delim " "))
(while (vl-string-search pattern str)
(setq str (vl-string-subst delim pattern str))
)
)
)
(vl-string-translate " \t" ",," str)
)
(progn
(foreach test
'(
"0 300000.00 4000000.00 0.0"
"1 318445.61 4231568.79"
"2 318446.37,4231561.59,123"
"3 318443.36,4231549.82"
"4 318438.82 4231539.87 0.0"
"5 318428.56, 4231532.33, 0.0"
"6,318425.25,4231523.57,0.0"
"7, 318428.55, 4231513.05, 0.0"
"8 \t 318442.57 4231516.64"
"9 318455.87 \t 4231506.94"
"10 318473.12 4231495.81"
)
(princ (strcat "\n" test " >> " (_Normalize test)))
)
(princ)
)
While that is generally good advice, and Michaels comments regarding data formatting ;
I can understand the desire to be able to handle various formatting structures.
Having one function to parse the data file irrespective of it's structure is definitely an advantage if we are dealing with data from various sources.
I hadn't imagined the format would be as mixed in ONE file as the example I posted but being able to process ANY of the formats would be handy.
Good generic solution Fools.