如何在Ubuntu上安装g ++ - 4.7?(How to install g++-4.7 on Ubuntu?)
没有
g++-4.7
使用apt-get install
,apt-get install
提供的所有g++
版本都等于或低于4.6,那么如何安装g++-4.7
?There is no
g++-4.7
withapt-get install
, allg++
versions provided byapt-get
are equal to or under 4.6, so how can I installg++-4.7
?
原文:https://stackoverflow.com/questions/15062400
最满意答案
这是因为根据您尝试上传的CSV文件的大小,文件类型可能是StringIO或TempFile对象。 所以你可能会采取适当的行动,具体取决于它是什么。 请参阅此答案以获得解释。 接下来,您的代码变为:
file_data = params[:file] if file.respond_to?(:read) csv_text = file.read elsif file.respond_to?(:path) csv_text = File.read(file.path) else logger.error "Bad file_data: #{file.class.name}: #{file.inspect}" end @rowarraydisp = CSV.parse(csv_text, :headers => true)
另外,您在
form_tag
指定了GET方法,在上传表单的情况下,您要发布数据,因此我只是完全删除该方法或正确指定方法作为post。That's because depending on the size of the CSV file you're trying to upload, the type of
file
might either be a StringIO or TempFile object. So you may wan to take appropriate action, depending on which it is. See this answer for an explanation. Following that your code becomes something like:file_data = params[:file] if file.respond_to?(:read) csv_text = file.read elsif file.respond_to?(:path) csv_text = File.read(file.path) else logger.error "Bad file_data: #{file.class.name}: #{file.inspect}" end @rowarraydisp = CSV.parse(csv_text, :headers => true)
Also, you have specified method as GET in
form_tag
, in your case when uploading a form, you are posting data, so I'd just remove the method altogether or correctly specify the method as post.
相关问答
更多-
这是因为根据您尝试上传的CSV文件的大小,文件类型可能是StringIO或TempFile对象。 所以你可能会采取适当的行动,具体取决于它是什么。 请参阅此答案以获得解释。 接下来,您的代码变为: file_data = params[:file] if file.respond_to?(:read) csv_text = file.read elsif file.respond_to?(:path) csv_text = File.read(file.path) else logger.err ...
-
nil的未定义方法`path':尝试CSV导入时的NilClass(undefined method `path' for nil:NilClass when trying CSV import)[2022-03-13]
从评论:你很可能在没有选择文件的情况下提交表单:) From the comment: You are most probably submitting the form without choosing a file :) -
未定义的方法`illust_reports_path' 你有嵌套的资源 。 所以form_for应该如下所示 <%= form_for [@lesson, @illust_report] do |f| %> 并像下面一样更改illust_reports_controller的new方法 def new @lesson = Lesson.find(params[:lesson_id]) @illust_report = current_user.illust_reports.build end u ...
-
你没有正确使用分割器 。 multer的初始化需要在中间件代码之外进行 Multer自己的中间件(在init之后获得)需要在你的之前执行(以便它可以在访问之前解析请求)。 如果使用数组,则有多个文件以相同的参数名称上传,因此应该使用req.file ,而不是req.file 。 结合这些,你的代码变成: var Storage = multer.diskStorage({ destination: function(req, file, callback) { ...
-
为了从csv中提取列,我可能会执行以下操作: col_data = [] CSV.foreach(FILENAME) {|row| col_data << row[COL_INDEX]} 这应该比CSV.Table上的任何操作快得多 To pluck a column out of a csv I'd probably do something like the following: col_data = [] CSV.foreach(FILENAME) {|row| col_data << row[CO ...
-
如何将csv上传到S3或Dropbox,然后将网址发布到服务器,服务器读取该CSV并导入到数据库。 以下是从URL读取CSV的示例: 应用程序/服务/ process_csv.rb require 'csv' require 'net/http' class ProcessCsv def initialize(csv_url) @csv_url = csv_url end def proesss uri = URI(@csv_url) csv_text = N ...
-
Spark阅读CSV真实路径(Spark read CSV realtive path)[2022-12-23]
所以并不总是引起责备的火花;)我决定使用普通的scala获取相对文件路径: var path = "~/myProject/data/data.csv" path = path.replaceFirst("^~", System.getProperty("user.home")) So not always it is spark to be blamed ;) I settled on using plain scala to get the relative file path: var path = ... -
检查您的Ruby版本。 似乎在1.9.1中添加了 absolute_path方法。 Check your Ruby version. The method absolute_path was added in 1.9.1, it seems.
-
读取Csv文件编码错误(Read Csv file encoding error)[2022-03-13]
尝试在schema.ini文件中使用CharacterSet=UNICODE 。 虽然这在MSDN上没有记录,但它依照Microsoft论坛上的此线程工作。 Try using CharacterSet=UNICODE in your schema.ini file. Although this is not documented on MSDN it works according to this thread on Microsoft Forums. -
asset_path是一个视图助手。 它在Rails 4中并没有过时。 请访问 http://api.rubyonrails.org上的 #asset_path 。 这个类似的问答应该为您提供解决方案: 从Rails控制器访问资产路径 asset_path is a view helper. It is not obsolete in Rails 4. See #asset_path at http://api.rubyonrails.org. This similar Question and Answe ...