You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Likewise, you can specify which columns of the table should be read as strings instead of numbers. In this example, the entire first row will be read as a list of strings. From the second row onwards, the first and the fifth columns (nth 0 and 4) will also be read as strings.")
; "reads csv file at \"filename\" and returns a list of lists of floats (that corresponds to therows of the csv file)\n\nKeyword :defaultformat can be either long-float/double-float (default) or float/short-float/single-float."
"reads csv file at \"filename\" and returns a list of lists of floats (that corresponds to therows of the csv file)\n\n
29
+
Optional parameters rowsasstrings and colsasstrings can be nil or lists: they can be used to specify rows or columns of the original csv file that should not be read as float numbers.\n\n
30
+
Keyword :defaultformat can be either long-float/double-float (default) or float/short-float/single-float."
31
+
32
+
(with-open-file (stream filename)
33
+
(loop for line = (read-linestreamnil)
34
+
while line
35
+
for linecount from 0
36
+
collect
37
+
(loop for start =0 then (1+ finish)
38
+
for columnnumber from 0
39
+
for finish = (position#\, line :start start)
40
+
collect
41
+
(cond
42
+
(colsasstrings ;;se colunas forem especificadas
43
+
(if rowsasstrings ;; primeiro ve se é para printar toda a linha como string
44
+
(if (position linecount rowsasstrings)(string-trim"" (subseq line start finish)) ;;linha como string
45
+
(if (position columnnumber colsasstrings)(string-trim"" (subseq line start finish))(parse-float (string-trim"" (subseq line start finish)) :default-format defaultformat));; senão, ve se a coluna atual deve ser lida como string ou como numero
46
+
)
47
+
(if (position columnnumber colsasstrings)(string-trim"" (subseq line start finish))(parse-float (string-trim"" (subseq line start finish)) :default-format defaultformat))
48
+
)
49
+
)
50
+
(rowsasstrings (if (position linecount rowsasstrings)(string-trim"" (subseq line start finish))(parse-float (string-trim"" (subseq line start finish)) :default-format defaultformat)))
51
+
(t (parse-float (string-trim"" (subseq line start finish)) :default-format defaultformat)))
0 commit comments