我正在尝试运行以下代码,将一个.csv文件(可以看作是纯文本)减少到100行:
(ns tst.demo.core
(:require [clojure.java.io :as io] [System.IO.File])
(:import [java.io File]))
(defn lines [n filename]
(with-open [rdr (io/reader filename)]
(doall (take n (line-seq rdr)))))
(defn spit-lines [^String filename a-seq]
(->> a-seq
(System.Linq.Enumerable/Cast (type-args System.String))
(System.IO.File/WriteAllLines filename)))
(spit-lines(lines 100 "test_set_batch1.csv")))每当我运行此命令时,我都会得到以下错误:
Syntax error (FileNotFoundException) compiling at (RemoveAfterLine100.clj:1:1).
Could not locate System/IO/File__init.class, System/IO/File.clj or System/IO/File.cljc on classpath.我搞不懂是什么导致了这个错误。我将System.IO.File添加到:requires中,所以我认为它应该可以工作。
发布于 2020-09-03 06:00:29
正如@mange和@Alan Thompson指出的那样,我的问题是我试图同时在CLR和JVM上运行脚本。
https://stackoverflow.com/questions/63697807
复制相似问题