首页 \ 问答 \ 如何在Ubuntu上安装g ++ - 4.7?(How to install g++-4.7 on Ubuntu?)

如何在Ubuntu上安装g ++ - 4.7?(How to install g++-4.7 on Ubuntu?)

没有g++-4.7使用apt-get installapt-get install提供的所有g++版本都等于或低于4.6,那么如何安装g++-4.7


There is no g++-4.7 with apt-get install, all g++ versions provided by apt-get are equal to or under 4.6, so how can I install g++-4.7?


原文:https://stackoverflow.com/questions/15062400
更新时间:2022-06-30 12:06

最满意答案

这是因为根据您尝试上传的CSV文件的大小,文件类型可能是StringIOTempFile对象。 所以你可能会采取适当的行动,具体取决于它是什么。 请参阅此答案以获得解释。 接下来,您的代码变为:

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 ...
  • 从评论:你很可能在没有选择文件的情况下提交表单:) 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 ...
  • 所以并不总是引起责备的火花;)我决定使用普通的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.
  • 尝试在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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)