I am a newcomer in Ruby and I have the following code:
out_file = File.open('new1.csv', 'w')
File.open("new7.txt").each do |line|
if line =~ /Revision/ then
out_file.puts line
elsif
line =~ /Author/ then
out_file.puts line
elsif
line =~ /Date/ then
out_file.puts line
end
end
I need:
- The line with "Revision" put in column A in the output CSV file
- The line with "Author" put in column B
- The line with "Date" put in column C
- And so on
Can anyone show me how to put the data in columns as described?
Right now all lines are put in one row.
The sample of "new7.txt"
Revision: 37407
Author: imakarov
Date: 21 June 2013 г. 10:23:28
Message:
update specification from Jhon (it was in VTBSOATST-1219)
----
Added : /Analitics/Документы/ЧТЗ/BR-5610/2 Спецификации/BR-5610 Публикация клиентских данных в АБС Бисквит (CifOraSyncOffPers).docx
Deleted : /Analitics/Документы/ЧТЗ/BR-5610/2 Спецификации/BR-5610 Публикация клиентских данных в АБС Бисквит.docx
Revision: 37406
Author: imakarov
Date: 21 June 2013 г. 10:22:16
Message:
delete files
----
Deleted : /Analitics/Документы/ЧТЗ/BR-5610/2 Спецификации/ЧТЗ Принудительное обновление и публикация ФЛ с замечаниями Кочебина С..docx
Deleted : /Analitics/Документы/ЧТЗ/BR-5610/2 Спецификации/ЧТЗ Принудительное обновление и публикация ФЛ-comments.docx
Deleted : /Analitics/Документы/ЧТЗ/BR-5610/2 Спецификации/ЧТЗ Принудительное обновление и публикация ФЛ-comments_Орлов.docx
Deleted : /Analitics/Документы/ЧТЗ/BR-5610/2 Спецификации/ЧТЗ Принудительное обновление и публикация ФЛ.docx
Revision: 37405
Author: dboytsov
Date: 21 June 2013 г. 10:21:17
Message:
add attributes in file
----
Modified : /Analitics/Документы/ЧТЗ/BR-5864 Запрос данных клиента по интернет-анкете КН/Преобразование BR-5864.docx
Modified : /Analitics/Документы/ЧТЗ/BR-5864 Запрос данных клиента по интернет-анкете КН/ЧТЗ BR-5864 Запрос данных клиента по интернет анкете.docx
May be it would be a better way to export in .xls ? Is it a difficult to export in .xls file in each column inside?
Now I have the following situation:

But I need that:
