Tuesday 15 June 2010

Ruby: how to parse txt in xls? -


I'm a newcomer in Ruby and I want to parse the sample of the txt file (new7.txt) input the txt file Is: Revision: 37407 Author: Imarkov Date: 21 June 2013 г. 10:23:28 Message: Updated specification from John ---- Added (VTBSOATST-1219) in it: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / BR-5610/2 СпÐμÑ ?? DN ?? икР° N ?? DD / BR-5610 Ð ?? Ñ ​​?? Ð ± Ð »Ð¸ÐºÐ ° N ?? D Ñ ?? кР»Ð¸ÐμÐ½Ñ ?? Ñ ​​?? кÐÑÑ ?? Ð'Ð ° Ð½Ð½Ñ ?? Ñ ​​?? в Ð ?? Ð ?? С Ð ?? ÐÑÑ ÐºÐ²Ð - ÑÑ ?? (CifOraSyncOffPers) was deleted .docx: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / BR5610 / 2 СпÐμÑ ?? DN ?? D кР° Ñ ?? ¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸? ¸? ± ?? Ð ± Ð »Ð¸Ð º ° Ñ ?? ÐÑÑ ÐºÐ »Ð¸ÐμÐ½Ñ ?? Ñ ​​?? кÐÑÑ ?? Ð'Ð ° Ð½Ð½Ñ ?? Ñ ​​?? в Ð ?? Ð ?? С Ð ?? ÐÑÑ ÐºÐ²ÐÑÑ ??. Docx Amendment: 37406 Author: Imarkov Date: 21 June 2013 г. 10:22:16 Message: Delete Files ---- Deleted: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / BR5610 / 2 СпÐμÑ? ? DN ?? икР° N ?? DD / ЧРР¢ ?? Ð ?? Ñ ​​?? Ð¸Ð½Ñ ?? Ð'Ð¸Ñ ?? ÐμÐ »n ?? ноÐμ оР± новР»ÐμниÐμ D Ð¿Ñ ?? Ð ± Ð »Ð¸ÐºÐ ° N ?? Ð n ?? ФР?? Ñ ​​?? Ð · Ð ° мÐμÑ ?? Ð ° Ð½Ð¸Ñ ?? ми Ð ?? ÐÑÑ ?? ÐμÐ ± инР° С..docx was destroyed: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / BR5610 / 2 СпÐμÑ ?? DN ?? икР° N ?? DD / ЧР¢ Ð ?? Ð ?? Ñ ​​?? Ð¸Ð½Ñ ?? Ð'Ð¸Ñ ?? ÐμÐ »n ?? ноÐμ оР± новР»ÐμниÐμ D Ð¿Ñ ?? Ð ± Ð »Ð¸ÐºÐ ° N ?? Ð n ?? ФР?? - comments.docx Deleted: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / BR5610 / 2 СпÐμÑ ?? DN ?? икР° N ?? DD / ЧРР¢ ?? Ð ?? Ñ ​​?? Ð¸Ð½Ñ ?? Ð'Ð¸Ñ ?? ÐμÐ »n ?? ноÐμ оР± новР»ÐμниÐμ D Ð¿Ñ ?? Ð ± Ð »Ð¸ÐºÐ ° N ?? Ð n ?? ФР?? - comments_Ð ?? Ñ ​​?? Ð »Ð¾Ð².docx was deleted: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? /BR-5610/2 С пÐμÑ ?? DN ?? икР° N ?? DD / D ¢ ЧР?? Ð ?? Ñ ​​?? Ð¸Ð½Ñ ?? Ð'Ð¸Ñ ?? ÐμÐ »n ?? ноÐμ оР± новР»ÐμниÐμ D Ð¿Ñ ?? Ð ± Ð »Ð¸ÐºÐ ° N ?? Ð n ?? ФР??. Docx Revision: 37405 Author: dboytsov Date: 21 June 2013 г. 10:21:17 Message: adding attributes to the file ---- Modified: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / B R-5864? Ð ° Ð ¿Ñ ?? ÐÑÑ ?? Ð'Ð ° Ð½Ð½Ñ ?? Ñ ​​?? кР»Ð¸ÐμÐ½Ñ ?? Ð ° по Ð¸Ð½Ñ ?? ÐμÑ ?? нÐμÑ ?? - D ° нкÐμÑ ?? Ðμ Ð ?? Ð ?? / D ?? Ñ ​​?? ÐμоР± n ?? Ð ° Ð · овР° ниÐμ BR-5864. docx Modified: / Analitics / D ?? Ð¾ÐºÑ Ð¼ÐμÐ½Ñ ?? Ñ ​​?? / ЧР¢ Ð ?? / B R-5864? Ð ° пÑ? ? ÐÑÑ ?? Ð'Ð ° Ð½Ð½Ñ ?? Ñ ​​?? кР»Ð¸ÐμÐ½Ñ ?? Ð ° по Ð¸Ð½Ñ ?? ÐμÑ ?? нÐμÑ ?? - D ° нкÐμÑ ?? Ðμ Ð ?? Ð ?? / ЧРР¢ ?? Br-5864 Ð ° Ð¿Ñ ?? ¾zan ?? Ð'Ð ° Ð½Ð½Ñ ?? Ñ ​​?? кР»Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ð Ñ Ñ ?? Ð ° нкÐμÑ ?? Ðμ.docx

Stackoverflow helps associates me with programm:

  requires 'CSV' data = [] File.foreach ( "New7.txt"). Line | Line.chomp! If line = ~ / modification / data Push [line] Elsef line = ~ / author / if data is not there and data is not. Unknown [1] data Unknown [1] = line other data Push [zero, line] end LELF line = ~ / date / if there is no data and data is not there. [2] data No [2] = Line other data. Push [zero, zero, line] end end end CSV.open ('new1.csv', 'w'). CSV | Data. Record | CSV & LT; & Lt; End of record end   

But now I have the following transfers: Image details here Enter

and I need it:  Enter image details here

I can use an export in .csv. Will it be a better way to export in .xls? Is it difficult to export in .xls file inside each column? I have such an input term (new 7.txt) as "amendment" "author" "date" and so on. This is not a column in the input file and I want to parse this input file and copy the .xls in the column

From:

"Microsoft Excel .ccv files open, but depending on the system's regional settings, it can expect a semicolon instead of a comma Because in some languages ​​the comma is used as a decimal separator. "

You specify : col_sep to specify the column separator You can use the option. it should work.

  CSV.generate ('new1.csv', 'w', {col_sep: ";"}). Csv | Data. Record | CSV & LT; & Lt; Record End End    

No comments:

Post a Comment