小编cas*_*des的帖子

使用不同的文件名在Python中合并CSV文件

我是Python的新手,所以这个问题可能有点基础.我有44个csv文件具有相同的标题和不同的文件名.我想将它们全部合并到一个文件中.

每个文件名为"Votes- [member-name] - (2010-2014) - [download-time] .csv"

标头不包含成员名称的列.我想补充一点,作为第一项.

这是我想要做的部分:如何在Python中合并200个csv文件.我只是不确定如何遍历具有不同名称的文件,并将这些名称添加到csv.

谢谢!

python csv

5
推荐指数
1
解决办法
1997
查看次数

Rails Mailer 上的 RSpec class_spy

我正在尝试测试保存模型时是否使用特定的邮件程序类。在我的模型中我有:

class Foo < ActiveRecord::Base
  def send_email
    if some_condition
      FooMailer.welcome.deliver_now
    else
      FooBarMailer.welcome.deliver_now
    end
  end
def
Run Code Online (Sandbox Code Playgroud)

在我对 Foo 类的测试中,我有以下内容

it 'uses the foo bar mailer' do
  foo_mailer = class_spy(FooMailer)
  subject.send_email
  # some_condition will evaluate to false here, so we'll use the FooMailer
  expect(foo_mailer).to have_received :welcome
end
Run Code Online (Sandbox Code Playgroud)

当我运行此测试时,它失败并显示:

(ClassDouble(FooMailer) (anonymous)).welcome(*(any args))
       expected: 1 time with any arguments
       received: 0 times with any arguments
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails actionmailer

5
推荐指数
1
解决办法
1570
查看次数

标签 统计

actionmailer ×1

csv ×1

python ×1

rspec ×1

ruby-on-rails ×1