How do I create a text file so when it is opened in Excel, rows are grouped together? - perl

I'm collecting some data via a Perl script. The data needs to be reviewed and processed by others using Excel. Currently, I'm writing the data out as a tab-delimited text file, and Excel can open this just fine.
There's a hierarchy to the data, however, and it would be easier for the reviewers to see a tree rather than a flat list. That is, rather than presenting the data in columns,
foo foo1
foo foo2
foo foo3
bar bar1
bar bar2
...
present it as a click-to-expand tree:
foo
foo1
foo2
foo3
bar
bar1
bar2
...
Excel's group function (found in 2007 under "Data > Outline > Group") is a good match for this presentation, being a bit simpler to operate than pivot tables.
What is the easiest way for us to go from this flat list of columns to this grouped list? Ideally, I could write out the data in a text form that Excel would apply the grouping automatically when it was imported. Alternatively, if there were a small number of steps the reviewer could apply after importing the data, like applying a macro or a template, that would be OK too.

Since you are already using perl, I suggest that you create the excel file directly in perl using the excellent CPAN module Spreadsheet::WriteExcel which has support for Excel outlines.
Works something like this:
.
.
$worksheet->write('A2', 'foo');
$worksheet->write('B3', 'foo1');
$worksheet->write('B4', 'foo2');
$worksheet->write('B5', 'foo3');
$worksheet->set_row(2, undef, undef, 0, 1, 1);
$worksheet->set_row(3, undef, undef, 0, 2);
$worksheet->set_row(4, undef, undef, 0, 2);
$worksheet->set_row(5, undef, undef, 0, 2);
.
.

Select all the rows, including the column headers, in the list you want to filter.
ShowTip
Click the top left cell of the range, and then drag to the bottom right cell.
On the Data menu, point to Filter, and then click Advanced Filter.
In the Advanced Filter dialog box, click Filter the list, in place.
Select the Unique records only check box, and then click OK.
The filtered list is displayed and the duplicate rows are hidden.
On the Edit menu, click Office Clipboard.
The Clipboard task pane is displayed.
Make sure the filtered list is still selected, and then click Copy Copy button.
The filtered list is highlighted with bounding outlines and the selection appears as an item at the top of the Clipboard.
On the Data menu, point to Filter, and then click Show All.
The original list is re-displayed.
Press the DELETE key.
The original list is deleted.
In the Clipboard, click on the filtered list item.
The filtered list appears in the same location as the original list.

Recent versions of Excel (2003 is what we use here) can use an XML format, xlsx. An xlsx file is a zip of an XML file. If you want to make a file that will open in Excel with the settings you want, try this: first create a template file with the grouping you want. Save it as xlsx. Unzip the file using your standard zip software. Take a look at what's inside. I haven't worked with grouping specifically, but all the commands in your spreadsheet will be there in xml form, you'll need to figure out where the grouping is set. Then it's a matter of making the appropriate changes to the xml and re-zipping. A bit of effort, but you can use this method to programmatically create files that are pre-grouped. There may be Perl libraries specifically geared towards this, I don't know.

A CSV file is also very easy to generate. OpenOffice lets you choose how to parse things, but excel excepts comma-delimited columns (without any kind of quote) and CRLF delimited rows.
A1,A2,A3
B1,B2,B3
etc.

Related

How customize results in Recoll?

Please tell me how to display in the result sheet the full string of the word you are looking for, and not in pieces as in default in Recoll,I'll try in more detail:
I have recoll installed on my computer (which uses Xapian).
There are so many files.
I want to use recall as an alternative to grep
I indexed my data and search, but in the resultant window I do not like the output:
I want the whole row to be highlighted as if in a grepe, where I have the search word and output it immediately to the Result Sheet.
And now it looks like it gives out a piece of text where the searched word is found, but only partially, then it is divided by several points and again a piece of text, and again. You can see an example in the image, for example here (default settings) https://i0.wp.com/www.linuxlinks.com/wp-content/uploads/2018/01/Screenshot-Recoll.jpg?resize=768%2C596&ssl=1
This is how recoll works. It shows you "snippets" of text around the search hits. You can adjust the snippets parameters (size and number of context words) in the preferences Gui Configuration, Search Parameters section. You can also hit Preview, and then shift down/up arrows, to browse the result documents previews, for a more complete view.

Cross-reference list is empty in Word 2010

I have been given a Word file (.docx) that has about 35 figures and tables. When I try to add a cross-reference I get an empty list like this:
I made sure that:
1) The figures and tables are actually captions. If I delete anyone of them, the rest get updated as expected.
2) Other cross-references already in the file works. They get updated correctly like in (1)
3) The document doesn't have any 'track changes'. This is apparently a problem for some people, so I did an 'accept all changes'. Doesn't seem to help unfortunately.
4) I tried copy all and paste into a new file.
5) I tried selecting all and F9.
I'm perplexed why this is happening. Anyone can help me find the root cause?
I know that it is probably late, but maybe it will help somebody else.
Select caption below table/picture
Right click and select Toggle field codes - the caption show the code in format like SEQ xxx xxx
Go to Insert -> Reference -> Caption and click on New Label button
Insert the text following after SEQ from point 2. E.g. Fig.
Save the new label.
Go to Insert -> Reference -> Cross Reference - select the inserted value from point 4 in the Reference type dropdown list. Now you should see all the values.
The answer is based on the following link.
In Word 2013, instead of Insert>Reference>Caption, right click on a figure or table and select insert caption. A dialogue box including the option New Label will appear.
In my case, I think this issue arose because of changes in language. The tables are all captioned with the French Tableau, but in insert references, it had Table and a blank list.

Libreoffice/Openoffice Calc - append string to cells

I need to add .jpg at the end of all he cells in one or more columns
9788895249971 into > 9788895249971.jpg
9788867230129 into > 9788867230129.jpg
9788867230273 into > 9788867230273.jpg
9788867230280 into > 9788867230280.jpg
Detailed step-by-step instructions are much appreciated since I am very new to Calc.
Thanks
Do you need to do this once or is this going to be a repeated task every week/month?
If it is something you need to do just once, here is what you can do:
Next (right) to the column where your numbers are open (insert) a new column.
Assuming the following: Numbers are in column A, New column is column B.
In this new column B in the top cell (B1) write:
=A1&".jpg"
Now copy B1 all the way down to the end. In B1 type [Ctrl]+c then Hold [Shift] and hit [PgDn] until the end then press [Ctrl]+v.
Highlight Column B, [Ctrl]+c, then [Edit] [Paste Special] values only (No formula's) this freezes the calculated data.
This is just another option,
just click the function wizard and select concatenate, in that enter which column you want to enter as text1 as and second column in text2. Then when you click OK you will get an concatenated column like below image
so in the C column you will get as a1.jpg.
For those who continue to find this question (as I did):
This can be quickly done using regular expression option of find and replace. (I don't know what version of Calc introduced regex searches, but 6.2.4 has it.)
If you only want to update some non-blank cells on the sheet, select them.
Choose Find and Replace.
On the dialog, fill in the following:
Enter $ for the Find value. ($ means end of line in regex, or in this context end of cell value.)
Enter the desired suffix (.jpg in the question) for the Replace value.
Check Regular Expressions under Other Options
Check Current Selection Only under Other Options if you want to limit to the cells selected in step 1.
Uncheck All Sheets unless that is what you want.
Choose Replace All
This will update the values in-place and does not require any additional columns or formulas.
There's a much more elegant way to do this that doesn't require sacrificing cells just to hold data types, and can be scaled to work with one cell or a large chart range.
Add both pieces of data into the =CONCAT() function
Make sure to use CONCAT instead of CONCATENATE, as `CONCAT accepts cell ranges and is more dynamic.
Open the Function Wizard on the cell in question, and build the following function:
=CONCAT(<your_data>," <suffix>",...)
# Make sure to add a space before the suffix so it appears in the cell.
# You can use this with as many input variables as required letting
# you add as many strings, formulas, or numbers together.
The result should be something like this. In my example, the cell in question is the final value of Ethereum on a balance sheet:
The above example was an easy one, since it was being used as a test, all my summed values were ints, if I had floating point numbers, they would run away to max decimal places (not very pretty).
The function will drag out and expand intelligently to other cells like any other formula.
Adjusting accuracy of floating point values inside a CONCAT function
Sometimes, adding a cell results in a rounding problem, or an extreme amount of decimal places. You can further nest your function using ROUND(<your_data>,<decimal_places>)
Your function would look like this:
=CONCAT(ROUND(<cell_range>, ".jpg")
In your specific case, you don't need a space in the second argument as you want to append .jpg directly to the end of the string.
`
Using Macros to automate the entire process
This is extremely repeatable, and using the Macros feature, you can automate these to make much more simplified functions that allow you to enter just the variables you need, while the macro does the work in the background.
Based on Emmanuel Angelo R.’s answer, I would advice learning to differentiate between fixed cell references and dynamic ones. The following applies:
Cell A1 contains the suffix you would like to add, e.g. ‘.jpg’
Row 2 contains headings, e.g. B2 = ‘Old Filename’ and ‘New Filename’
Cells A3:A¹ contain your filenames
Cells B3:B contain you concatenation formula
In cell B3, type =concatenate(A3;$a$1).² If your locale requires comma as separator, replace my semicolons with commas. Copy cell B3 by selecting it and pressing Ctrl + C. Move the cursor to cell A3, press Ctrl + ↓ (down arror on your cursor keys); this will move you to the bottom of the list of file names. Move your cursor right, then press Ctrl + Shift + ↑; this will select all cells up to the last cell with contents (the one you just wrote your formula in). Press Ctrl + V to paste your contents.
Adding dollar signs in front of your row/column coordinates, will lock that coordinate when pasted. Say you had a list of file types in cells b1–z1 (e.g. jpg, jpeg, tga, bmp, png et c.). An easy way to create the formula would then be by first typing it in cell B3 as =concatenate(A3;B$1), then paste it to every cell till the end of your file names list (cell z3); these cells would then read …A3;b$1, …A3;C$1 et c. When copying it for all the rows below
You could select the entire range of cells with formulas in row 3 and run a search and replace, replacing all instances of ‘A3;’ by ‘A3;$’, effectively inserting a dollar in front of all the cell references, allowing you to, should the need arise, copy it horizontally as well as vertically (the latter being covered by the $ in front of 1).
¹ This means cells from A3 and however far down your sheet goes
² Strictly speaking, it is only necessary to type it as a$1.

merging column in libreoffice calc does not work when drag down

I'm merging columns in Libre Office using the CONCATENATE function.
I'm merging all text using:
CONCATENATE(A1," ",B1," ",C1," ",D1," ",E1," ",F1," ",G1)
According to this suggestion, I should be able to apply the function over the whole column by dragging the plus sign; however, when I drag the plus sign, it only copies the first line, but I want to merge the next row.
How can I merge the columns correctly?
#oczdref, I am not sure why this would not work in your situation. Here is what I did (please ignore the ; separators, in your case they should remain ,)
I also found out that you must enable the "AutoCalculate" under Tools -> Cell contents
so that when you drag the autocomplete function instead of getting the result
something like this:
and the result that i want to.

Preserve Word list numbering when importing file into DOORS

I am importing a requirements document in created in Word into a DOORS module. I also want to be able to export the DOORS module back into a Word document and have them look mostly-similar. What is the easiest way to do this?
There are two options to do this that I can see:
In Word, use the DOORS add-in to "Export to DOORS"
In DOORS, use "Import -> Rich Text Format" (on the Word file saved as a RTF)
In Option 1, the numbering for the items in a list are not preserved. In Option 2, the line numbering is preserved, but upon exporting back to Word, the list Word styles are all "normal" and I lose all the formatting and indenting.
In Option 1, I can take advantage of the "Paragraph Style" attribute that is populated when the initial export is performed to make the resulting Word document look like the original. In Option 2, I do not see this option/attribute available.
There does not appear to be a way in DOORS/Word to handle this natively. The best solution I could find is to first convert the Word auto-numbering to actual text using the VBA method ConvertNumbersToText(). Doing this allows me to keep the formatting/indentation in DOORS and also have the ability to export the database back to Word and have it look the same/similar.
The only minor issue is that the resulting document no longer uses the Word auto-numbering. This is not an issue for my purposes.