-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2014-01-14代码游戏 #24
Comments
Nice |
期待,搞起! |
#encoding: utf-8
#gem install spreadsheet
require 'spreadsheet'
#require 'net/ftp'
#gem install net-sftp
require 'net/sftp'
FileName_DATA = "user.txt"
FileName_LOCAL = "user.xls"
FileName_REMOTE = "user-remote.xls"
#Dir_REMOTE = "/home/bingo/RubymineProjects/user-test"
Dir_REMOTE = "/home/qadev/user-test"
Spreadsheet.client_encoding = 'UTF-8'
#user.txt文件内容如下:
#input = [
# ["id", "name", "age"],
# ["100", "赵天一", "22"],
# ["101", "钱来易", "25"],
# ["102", "郑钱花", "23"],
#]
#也可以从本地读取user.txt
#http://snippets.aktagon.com/snippets/246-how-to-parse-csv-data-with-ruby
input = []
File.new(FileName_DATA, 'r').each_line("\n") do |row|
colums = row.to_s.delete("\n").split(",")
#colums = row
puts colums
input << colums
end
puts input.size
#1. 将user.txt文件内容写入到user.xls中
#https://github.com/zdavatz/spreadsheet
#https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.md
book = Spreadsheet::Workbook.new
write_sheet = book.create_worksheet
row_num = 0
input.each do |row|
puts "row:#{row}"
write_sheet.row(row_num).replace row
row_num +=1
end
book.write FileName_LOCAL
#2. 将user.xls同步到自己的台式机
#SFTP
#https://github.com/net-ssh/net-sftp
#http://rubygems.org/gems/net-sftp
Net::SFTP.start('192.168.145.247', 'qadev', :password => 'xxx', :port => "xxx") do |sftp|
#sftp.dir.foreach(Dir_REMOTE) do |entry|
# puts entry.longname
#end
#sftp.mkdir! Dir_REMOTE
sftp.upload!(FileName_LOCAL, "#{Dir_REMOTE}/#{FileName_REMOTE}")
sftp.download!("#{Dir_REMOTE}/#{FileName_REMOTE}", FileName_REMOTE)
end |
小兵的_coding_技能越发犀利了! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
背景
Excel是某公司喜闻乐见的测试用例工具,前不久,又研发了新的自动化接口测试框架,使用Excel管理测试数据,效率提升不少。
杰哥的Javelin计划新增一个功能,将自动生成的数据直接输出到Excel文件中。
请你帮助杰哥实现这个功能吧。
步骤
user.txt文件内容如下:
id,name,age
100,赵天一,22
101,钱来易,25
102,郑钱花,23
其它
The text was updated successfully, but these errors were encountered: