Backing Up Files to Prevent Data Loss

It took years to figure this out and it’s not free, but I don’t ever lose files anymore. Not losing files is worth the $240 I pay for these services per year.

Do note that I use Linux as my operating system, which is part of the reason why I chose the software that I use to back up my files, but the services I use run on Windows and Mac as well. Also, I do have some technical know-how, but, honestly, the approach I’m going to recommend is really not that complicated and could be done by pretty much anyone if you spend a little time setting it up.

Active Files vs. Archive Files

One of the most important distinctions I have made over the years when it comes to my files is realizing that some of my files include current or active projects while other files are no longer active and can be archived. Active files are those that relate to current projects I have (I’m a college professor and do a lot of research). Any current research project, any files for classes I teach, and any files I need for service or personal affairs are considered “active.” Active means I am likely to need access to those files sometime in the next 6 months to a year. But, more importantly, I want active files to be accessible instantly on any one of my devices (I have two desktop computers, a laptop, a tablet, and a phone).

Any files that do not meet the criteria for “active” can be archived. Archived files are still relatively accessible with the system I will detail below, but not as readily as are active files. I can access them on my home network or via a website (as I’ll detail below), but they are not stored on all of my devices such that I can immediately access them. It takes a few minutes to access archived files. Examples of archived files are those for projects I have completed, old financial information, old class files, or old service files. Effectively, they are files that I do not foresee needing within the next 6 months to a year, but I could potentially need them at some point in the future, so I am not deleting them. Also included in my archive are photos, home movies, music, and other videos.

Active File Backup

To back up my active files, I use Dropbox. That’s not an affiliate link. I’m not getting any money for recommending Dropbox because I’m not necessarily recommending Dropbox. You could use a different backup program. The reasons I went with Dropbox are: (1) It runs on Linux. (2) It provides me with sufficient storage for my active files. And (3) it synchronizes my files across all my devices while also keeping a copy in the cloud.

Here’s the key to using Dropbox, though: ALL of your active files have to be stored in your Dropbox folder!!! All of them!!!

If you don’t store a file in your Dropbox folder and then your computer crashes and the hard drive is ruined, that file is gone, permanently. But if you store it in Dropbox, the fine folks at Dropbox will upload that to their cloud service and synchronize it to your other computers. Effectively, Dropbox provides real-time backup for your most critical files. I use just the Personal Plus plan, which is roughly $10/month and gives me 2 terabytes of backup. That is sufficient storage for my active files throughout the year. Since my files are my job, $120 per year to make sure I don’t lose any of them is well worth it to me.

Here’s a screenshot showing my Dropbox folder:

As I complete projects or, when the year ends, I archive my photos and other data from the previous year, moving those files out of my Dropbox folder and into my archive.

NOTE: For some people, a Dropbox plan may be sufficient space for both active and archive files. If you don’t have a lot of photos, don’t store any videos, and don’t create a lot of files, 2 terabytes is a lot of space and Dropbox may be all you need. If so, great. You can stop here. Get a Dropbox account and put everything in it and make sure it is running on your computer. Then, if something goes wrong, you’ve always got a backup of your files.

Archive File Backup

If you’re still reading this, I’m assuming it’s because you have a lot of files (or photos or videos) and you are looking for a reliable way to back those up. I use a two-pronged backup approach for my archived files, though the second part is really sufficient for most people.

First, I built a NAS device (NAS = Network Attached Storage). While it is very helpful, it’s actually not necessary depending on your device and how much storage you have. On my NAS, I have a raid with roughly 8 terabytes of storage. The raid is set up so I could lose up to 2 of the 4 hard drives without losing any data. In other words, my archived files are backed up across multiple disks, locally, such that I would not lose any data if one of my hard drives crashed. That is a key if you are doing local backups. But, the second part of the archive means that is also not entirely necessary.

Second, I use CrashPlan for backing up my archive. I originally started using CrashPlan when they had a plan for individual users. They have since switched that to a small business plan that is $10/month. The reasons I chose CrashPlan are pretty simple: (1) It runs on Linux. (2) It runs in real-time without me having to monitor it. (3) It doesn’t limit me to a specific amount that I can back up. (4) It has an option online that allows me access to my archived files, even though it is fairly slow.

Here’s a screenshot showing my NAS mounted on my desktop computer at home:

Why did I suggest above that you don’t need a NAS device to use CrashPlan? If you’ve got lots of files taking up lots of space on your computer, I’m guessing that you either have installed another hard drive in your computer or you have an attached storage device, like a backup hard drive. I can easily envision a scenario in which someone has a Windows computer with a 1 terabyte solid-state drive for their OS and primary programs, games, etc. but also a 10 terabyte disk drive also installed in their computer where they store their photos, videos, music, and other old files that take up a lot of space. On just that one computer, it’s possible to run both Dropbox and CrashPlan (though, you’d need quite a bit of RAM to do so). Dropbox would be used to backup active files and CrashPlan could be set to backup just files on the large disk drive. As a result, a NAS isn’t necessary. I went with a NAS because I want it to always be on, serving up videos and music to my other devices in my home and across the internet. But it is possible to use this approach without a NAS.

Conclusion

In summary, if you have mission-critical files that you need to back up in real-time, I strongly recommend a backup service like Dropbox. Consider those your “active” files and make sure they are always saved in Dropbox. If you want to keep older files that you don’t need on an active basis, create an archive (either a separate folder or a separate drive or even a separate computer) and use CrashPlan or a similar service to back up those files. With such an approach, the odds of you losing important files, including old photos, drops pretty precipitously.

 384 total views,  3 views today

Replacing Paragraph Breaks with Double Paragraph Breaks in LibreOffice Writer

Here’s the problem I was facing. I had a document with a lot of text that I had to analyze. The text had been copied from a spreadsheet and pasted without formatting to get rid of the cells. As a result, there was a single “return” or “paragraph break” between each passage of text. That made it difficult to know when one passage of text ended and the other began, even if I turned on non-printing characters (called “formatting marks” in LibreOffice). This screenshot illustrates the challenge:

In the screenshot above, I don’t have non-printing characters or formatting marks turned on so I can’t see that there are actually two paragraphs here with a paragraph break or return in the middle of that paragraph. When I toggle formatting marks in LibreOffice, I can now see the paragraph break (or carriage return) in the middle of the paragraph, but the paragraph still seems to bleed right through.

What I wanted to do was find all the paragraph breaks (or returns or carriage returns) and double them, so there were clear breaks between each paragraph. This is possible using the Find and Replace window in LibreOffice (Edit -> Find and Replace or CTRL + H).

However, my initial efforts to solve this problem didn’t work because there was some confusion over regular expressions. The LibreOffice documentation includes a list of regular expressions here. In case you’re not aware, regular expressions are basically combinations of characters that can be used to find different items in a file. For instance, “^” will find the beginning of a paragraph.

Where my confusion came in is that “$” will find the end of a paragraph, which is what I wanted. So, that was a good start. But entering “$$” into the replace field in the Find and Replace dialogue in LibreOffice replaced the paragraph break with two dollar signs, not two paragraph breaks. It turns out, the dollar sign symbol “$” only works to find paragraph breaks. To insert paragraph breaks, you need a different regular expression: “\n”. To add two of them, I used “\n\n”.

Here is what I used in my Find and Replace dialogue to replace all my single paragraph breaks with double paragraph breaks:

Clicking “Replace All” made this change on all 12 pages of the document. Here’s that same paragraph, but with two paragraph breaks.

 480 total views,  4 views today

LibreOffice Calc – Conditional Formatting

I haven’t used this feature of spreadsheet software as much as I probably should, but I have a spreadsheet I have been working with a lot lately and conditional formatting has been key to helping me orient myself in the spreadsheet. However, in the process, I realized that I am really a noob when it comes to conditional formatting. To help get myself up to speed, I created the following tutorial so I can reference it again in the future. (NOTE: I’m using LibreOffice 7.2.4.1 for this tutorial.)

Before I begin, what is conditional formatting? The basic idea is that you can change the look of a cell in a spreadsheet (or many cells) based on the contents of those cells (or other cells) without having to manually change the formatting of the cells. Instead, you “program” into the spreadsheet how you want cells to look assuming they meet specific criteria. Then, when you enter information into your spreadsheet, the cell formatting automatically updates to reflect the information in the cell.

Tutorial A – “Formula Is” Conditional Formatting

Let’s start with a very basic illustration. Let’s say I want to use a spreadsheet as a to-do list. Here’s how my spreadsheet looks, to begin with:

What I want to do is pretty simple. If I add an “x” to the Complete column for an item, I want that item to be crossed out. Effectively, I am going to change the font of the tasks to “strikethrough,” which crosses out the text. This way, I can quickly and easily discern which items are completed on my to-do list and which still need to be completed.

How do I set up the conditional formatting?

First, select the first cell (A2) that says “grocery shopping.” Then go up to “Format” on the menu and select “Conditional” -> “Condition.”

You’ll then get this window

An explanation of the window is in order. At the bottom, the range of cells to which the conditional formatting will apply is included. Obviously, this can be set to a range of cells or just a single cell. Right now, I have it applying to just a single cell, A2.

Where it says “Condition 1” is where you will build your condition statement. If you click on the drop-down arrow where it says “Cell value,” you’ll see a couple of additional options:

Those options are “Formula is” and “Date is.” This tutorial will cover two of the three options. For this one, we’re going to go with “Formula is.” The reason why we are going with “Formula is” is because we are going to use the information in a different cell, B2, to change the formatting in the current cell, A2. As the next tutorial will illustrate, you can also use the information in the same cell (e.g., A2) to change the formatting of that cell. So, select “Formula is.” You’ll notice that the window changes and you now just have a single box next to “Formula is” where you can enter your formula:

For our very simple to-do list, our formula will be pretty simple. We’re going to tell Calc to check to see if there is a lower-case “x” in B2. Here’s the formula: B2=”x”. (NOTE: If you want text or a character as part of your formula, it has to be inside quotes.) Here’s how it looks in the window:

Below that, we need to indicate how we want the formatting to change. If you click next to “Apply Style” where it says “Accent,” you’ll see a list of built-in formatting options:

Since we want to have the text crossed out and that isn’t one of the built-in options, we’re going to select “New Style”. We’ll then get this window:

We actually only need to change two things. First, name the style. Since we are going with “Strikethrough,” let’s call this “Strikethrough.”

Next, Strikethrough is a Font Effect, so we click on the Font Effects tab and look halfway down the screen to where it says “Strikethrough.” By default, it says “(Without).” Click on that drop-down and select “Single” (or “Double” if that’s your fancy).

When you’re done, click “OK” and you’ll be taken back to the original Conditional Formatting window.

That’s actually all we need to do for now. Click OK on that window, and let’s test our Conditional Formatting. To test it, type a lower case “x” in B2 and hit “Enter” to see if your formatting works.

Okay, one more thing and the first part of this tutorial is done. We applied that conditional formatting to just one cell, A2. But we want it to apply to all the cells in that list. How do we copy the formatting and apply it to the others instead of having to repeat the process above? Select A2 and right-click. You’ll get a context menu. Look for “Clone Formatting” and select it.

When you do, you’ll notice that the paintbrush icon on your toolbar is selected:

To apply the formatting you just cloned, select the cells you want to apply it to. Your cursor will change to a paint bucket. Click it over the selected cells and the conditional formatting will be applied to those cells. Now, test it. Add an “x” next to one of the other items to see if your conditional formatting is working:

Congratulations! You’ve successfully set up your first conditional formatting in LibreOffice Calc.

(NOTE: You can also apply the conditional formatting by indicating the cells to which the formatting should be applied in the Conditional Formatting window at the bottom. We indicated just A2 above, but you could include a range like A2:A6.)

Tutorial B – Conditional Formatting a Range with Colors

For this next tutorial, we’re going to get a little fancier. Nothing too crazy, but we are going to make the formatting conditional on the values in the cell and then apply background color to the cells. Our sample data are test scores.

First, let’s select the top test score in B2 and go to the “Format” menu, then select “Conditional Formatting” -> “Condition.”

We’ll get the same window as we got in Tutorial A. But things are going to be different from here on. We’re going to set up a color code that reflects test score ranges so we can quickly see which students are doing well and which may need extra help. To do this, in that window, leave “Cell value” as is and select the next dropdown. We’re looking for “is greater than or equal to”:

We want that option because the first condition we are going to enter is our top range of scores – 90 and up. Now, in the box next to that, enter 90. (NOTE: No need for quotes as this is a number, not text.)

Now, the style. We are going to apply a colored background based on these ranges. So, in the dropdown next to “Apply Style” select “New Style”:

Like we did above, we’re going to name our style, something like “grades_best”.

Next, click on the “background” tab then select “Color” and you’ll see this:

You can now pick the color you want to use as the background for that cell. I like green to mean that a student is doing well. So, I’m going with that:

When you’ve picked your color, select “OK.” That will return you to the conditions window. We have our first condition, but we wanted to assign colors based on ranges. That means we need additional conditions. In that window, click on “Add.”

When you click on it, you’ll get “Condition 2.” We’re going to follow what we just did for Condition 1, but we’re going to change a couple of things. First, in the dropdown next to “Cell value,” we don’t want “is greater than or equal to” anymore as our next range will have upper and lower values. So, we want “is between.”

Now, think carefully about how this will work. Our first Condition was equal to or greater than 90. We want this one to range from 70 to 89. Thus, will need to set the two values as 69 and 90 so it includes all the values we want but excludes 69 and 90. Once you have that, follow the same steps above to set the background color you want. I went with blue for doing okay and named that style “grades_good”:

We’re going to set up two more conditions. One is going to be from 60 to 69 and is going to be orange. The last is from 0 to 59 and is red! Like this:

When you have all your conditions in, click “OK.” The background color for B2 should now change to match the conditions you created. You can test it by changing the values in B2 to make sure everything works.

Now, as we did above, we can copy that conditional formatting and paste it to the other cells we want to have that formatting. Right-click B2 and select formatting then select the cells where you want to apply it and click with the paint bucket. All of those cells should now have the same conditions as B2.

There you go. That is how to use multiple conditions to format cells with a range of values.

Some Useful Notes

If you want to change the conditional formatting for a cell, be careful. If you right-click a cell with conditional formatting and select “Conditional Formatting” you’ll get this rather uninformative warning window:

In this version of LibreOffice, whether you select “Yes” or “No” doesn’t seem to matter, it wipes out the current formatting. So, don’t do that. Instead, select the cell you want to modify, then click on the “Format” menu at the top of the window and select “Conditional Formatting,” but don’t select “Condition”! Instead, click “Manage” and that will pull up the existing conditions. You can then modify the existing conditions from that window.

 801 total views,  9 views today

How To Fix PDF Forms Not Showing Contents in Okular (Linux)

I have had this problem happen twice now, and I don’t know exactly what is causing it, but I found a solution. Here’s the situation…

I received a PDF that has forms. Typically, that isn’t a problem as Okular is able to open most PDFs with forms and show both the forms and what has been entered into the forms. However, with this particular PDF, when I click on the “Show Forms” button at the top of Okular, I can see the information entered into the form like this:

(NOTE: I tried opening the PDF in Xournal and had the same problem.)

But when I click on “Hide Forms” (which is still showing on this PDF as “Show Forms” for some reason), all of the information entered into the form goes away, like this:

If I try to save the PDF as a different PDF in Okular or print it, nothing shows up. I found one website that had a suggestion for why this might be happening – the PDF may have been filled out in a web browser instead of using Adobe Acrobat Reader (or Okular) and, as a result, the PDF that was saved has some problem. I’m not sure what browser would be doing this, but that gave me an idea. If the problem is that it was filled out in a browser, perhaps I can open it in a browser then print it to PDF. So, that’s what I tried and it worked.

I opened the PDF in Brave (one of the browsers I have installed on Linux) and the PDF showed all the forms with all the information filled in:

I then printed the PDF (which flattens it and removes the forms) using the print button to a PDF:

The resulting PDF, while flattened, now showed all the information in the forms and allowed me to sign the document electronically.

I’m not sure how I solved this last time, but I figured I’d post this solution up here for the next time this happens so I can quickly take care of the problem and don’t have to try to figure out why form information isn’t showing up in my PDF on Linux using Okular.

 929 total views,  5 views today

Plex Playlists with Amazon Echo

My music library is stored on my NAS. On my primary desktop at home, I mount the music folder and use Clementine to listen to my music. Everywhere else, I use Plex to play my music. Playing my music through Plex via my browser at work, via my Roku in the family room, and via the Plex Amp app on my phone, all works great. What doesn’t always work great is playing plex with an Amazon Echo device.

The first issue is that sometimes after I open Plex and tell it to play something, it just ignores me and does nothing, which is really annoying. I don’t have a solution for that problem. I may try to figure that out at some point.

The second issue is the one that I finally figured out. I have a number of really generic smart playlists that I have auto-generated in Plex. Most of these are generated based on the genre of music – Folk, Classic Rock, Alternative, Classical, etc. I’m all about keeping things simple, so I originally named most of those smart playlists in Plex as just the genre. In other words, my Folk playlist was literally just named “Folk.”

Enter the problem. I would say to my Amazon Echo, “Open Plex.” Plex would open fine. Then I would say something like, “Play playlist Folk .” My Echo would then say, “I’m sorry, I didn’t catch what you wanted to play. Try asking again.” For months (maybe even years), I just assumed that the Plex Skill was subpar and couldn’t do what I wanted it to do. I even double-checked with Plex’s list of Alexa Voice Commands to make sure I was saying things exactly right. But one day, for some reason, I had an epiphany: What if my Amazon Echo is getting confused with the genre and the playlist?

It turns out, that may have been the problem all along. I don’t know that for certain, but I ran a little experiment and that may have been the case. I created the exact same smart playlist in Plex that contained all my music in the genre Folk but named it “Favorite Folk” instead of just “Folk.”

This video shows the results:

So, word of advice: If you want the Plex Skill to play your playlists, name them something unique that does not overlap with the genre. Otherwise, the Plex Skill and your Amazon Echo will get confused and not play them.

 2,202 total views,  5 views today

LibreOffice – address label merge (from spreadsheet)

I’ve been using LibreOffice for over a decade and have only had to do an address label merge twice in that time – both of which have been in the last month. The first time, I actually did a form letter and a label merge; the second time I just had to do an address label merge. In the process, I realized that I totally forgot how to do it after the first time. Whenever that happens, I know that means I need to create a tutorial on here so I can remind myself how to do it if I ever need to do it again. So, here is my tutorial on how to merge labels in LibreOffice. (NOTE: I’m using LibreOffice 7.1.6.2.)

The idea behind a label merge, just like a form letter merge, is that you have a bunch of address information in a spreadsheet or database and, rather than having to enter all of that separately into a document to print labels, you’ll just have the software create the labels from the data you already have. LibreOffice is fully capable of doing this, but it’s not what I would call “easy” or straightforward. And, in fact, the first step will seem unrelated to merging labels, but it is necessary.

Part 1: Register Your Database with the Address Book Data Source Wizard

Before creating any labels, the first thing you need to do is create your database. I’m assuming you have a spreadsheet with addresses, like this one:

Make sure that you have column names at the top as those can become the field names in the database. It’s always a good idea to separate out your fields like I have done: first name, last name, street, city, state, zip. Of course, if you’re outside the US, your columns will be different. Adjust accordingly.

Okay, now we get to the weird part that is going to seem unrelated to merging these addresses into labels. A quick explanation may help. Basically, you need to turn this list of addresses into a database that LibreOffice has registered so it can then pull those fields when it generates the labels. This isn’t hard to do. LibreOffice will walk you right through it with a wizard. But it seems counterintuitive that you have to do this before you can start the mail merge. Just think of this as getting everything set up.

To create your database, click on File -> Wizards -> Address Data Source:

When you click on that, you’ll get this window:

This is Step 1 of 5 for the wizard. It’s basically saying, “Hey, let’s use existing data instead of having to enter new data.” Groovy. That will save us time. Unless you have your address data stored in Firefox or Thunderbird, select “Other external data source.” Then click on “Next” and you’ll get this next screen:

This is Step 2 of 5 for the wizard. On this screen, click on “Settings” and you’ll get a completely separate window:

(Did I mention that this is a bit confusing and complicated. It’s actually really smart, when you think about what the programmers did here, but it isn’t straightforward at all that you have to do all of this first. We’re only about halfway done.)

You have a lot of options you can choose from on this screen. I’m using a Spreadsheet, so I’ll leave that selected. But you can see from this screenshot that you choose from a variety of database sources:

Once you’ve selected the source for your data (again, I’m using a spreadsheet), select “Next” and you’ll get this screen:

Here, you need to choose your data source. Click on “Browse” and go find the spreadsheet you are going to use, like this:

Click on “Open” once you’ve selected it. That will take you back to the previous screen. If you want, you can click on “Test Connection.” Assuming everything worked, you should get this nice but relatively uninformative window:

Click on “Finish” and you’ll go back to the wizard:

This is Step 4 of 5 (note, Step 3 was skipped because I only had one field in my spreadsheet). On this screen, you can click on “Field Assignment,” which will let you match the fields in your imported data to the fields that are common for addresses. (NOTE: This is not required. You can skip this step if you want. It just changes the names of the fields later.) Here’s what the screen should look like:

Just to be clear, the Data source field is what LibreOffice is currently calling the newly imported data (in the image above, it just says “Addresses”). You’ll get a chance to change this later. The Table field (mine is called “Sheet1”) is the table in your spreadsheet where the address information was stored. You can then click on the various fields below where it says “Field Assignment” and align your information with the information options given, like this:

Once you’re done, hit OK and you’ll head back to the wizard.

This is Step 5 of 5. Phew. We’re almost done with this first part. You have a couple of options here. The first is a checkbox that says “Embed this address book definition into the current document.” You can unclick that if you want. Alternatively, you can leave it checked and make it part of the spreadsheet you are working on, which is fine. It really kind of depends on what your future plans are with this data. If this is data that you think you will use repeatedly for mail merges and you’ll probably be updating the data in the future, it might be a good idea to leave that checked. The second option is the one you definitely want to leave checked because we’re going to need it accessible for the label merge we’re going to do next. That option is also a checkbox that says “Make this address book available to all modules in LibreOffice.” Finally, you can name this address book. Call it something you’ll remember. I’m going with “folk artist addresses.” This changes the name that LibreOffice had temporarily assigned it (see the screenshot just above this). Once you’ve made your selections and named your Address Data, click “Finish”:

And once you hit “Finish,” nothing, right? Well, isn’t that weird.

Something did happen, it’s just “behind the scenes.” You have created a database that is now registered with LibreOffice. It’s just not showing it to you. If you want to see it, here’s how. Click on View -> Data Sources:

You’ll then see this:

You can see that I’ve got four Data Sources registered with LibreOffice. One of those is, of course, the one I just created: folk artist addresses. You can actually work with those data sources here if you’d like. Or, if you want to delete one (say, you made one by mistake or for a tutorial and you’ll never need it again), you can right-click on any of the databases and you’ll see this menu:

If you select “Edit Database File,” the LibreOffice database software will start up. If you select “Registered databases,” you’ll see a list of your databases with an option to select them and delete them, like this:

Okay. That does it for the prep work and part 1 of the tutorial. Now, with our address book registered, we can actually do the label merge.

Part 2. Label Merge In LibreOffice

Honestly, the first part is the hardest part. This next part goes pretty quick.

From any document in LibreOffice (it can be a Calc or Writer document; doesn’t matter), click on File -> New -> Labels:

You’ll then see this window:

Some explanation is in order. The big box is where you’re going to construct your addresses. I’ll walk you through that. The little check box at the top that has “Address” next to it is kind of nifty. If you’re a good LibreOffice user, when you first installed the software, you’ll click on Tools -> Options and fill in your User Data:

If you actually did that, you can click that little check box by “Address” and you’ll see your information populate the field:

This is a really slick way to, for instance, create business cards. But that’s not what we’re trying to do. So, uncheck that box and let’s get to merging some labels. First, in the drop down menu under “Database,” select the database we just created (and now Part 1 makes sense):

In the drop down menu under “Table,” select “Sheet1” (it’s the only sheet we had; we could always have named it something else). So, your window should look like this now:

Next, we start working with the drop down menu under “Database field.” In that menu, you should see all the fields you had in your spreadsheet:

Let’s build our address label. Select “firstname” then click on the little arrow pointing left:

That will insert that field into the label box, so you’ll see this:

Now, build the rest of your label, keeping in mind that you’ll want to add spaces and punctuation in between the fields, so it looks like this:

Once you’ve got it set up how you want it, we have a few other things we need to do. At the bottom, you need to choose between “Continuous” or “Sheet.” I’m assuming the Continuous is for printers that can print on labels that are connected. I typically print on individual sheets, so I select that. On the bottom right, find the “Brand” you want and then the “Type.” (Honest Aside: LibreOffice doesn’t always have every option I need for this, but you can usually find something that will work.)

We’re almost done. At the top of that window you’ll see two other tabs: “Format” and “Options.” If you want to customize the dimensions of your label, click on the Format tab. I rarely use this option, but it might be useful if you have a custom label you want to print. There is one thing on the “Option” tab that you probably want to select: “Synchronize contents”:

This will allow you to synchronize any formatting you do to the labels later. Trust me, you’ll want this option like 99% of the time. Once you’re done and have your label selected, click on “New Document” at the bottom.

You’ll then get an entirely new Writer file with labels spread out across the document and your fields highlighted in gray:

What you won’t see, unfortunately, is the actual data in those fields. That will come later. What you’ll want to do now is customize your label formatting. So, if you want to change the font, the font size, make the text bold or italicized, now is the time to do it. And, do it all in the top-left cell. In my document, I increased the font and made everything bold:

Remember when I said to choose “Synchronize contents.” Yeah, now is when you’ll want that. You don’t have to format every individual label. Just format the first one, as I said. And when you’re ready, click on the “Synchronize Labels” button in the floating window that popped up:

When you do, the formatting from the first cell transfers to all the other labels. Way easier than formatting each cell individually.

Now, to print the labels. This part is also, unfortunately, a little confusing. Click File -> Print or just hit the printer icon on the toolbar and you’ll get this message:

“Your document contains address database fields. Do you want to print a form letter?”

What an unfortunate prompt. We’re doing a label merge, so “No.” But don’t choose No! We may not want to print a form letter, but there isn’t a separate prompt for doing a label merge. So choose “Yes.” (Nudge to LibreOffice programmers – fix this.)

When you do, you’ll get this window:

This is a little confusing, but it’s basically that same Data Source window you saw in Part 1, but now we are applying it. You’ll see your Address Data Source on the top left. If you select your sheet (Sheet1 in my screenshot) you’ll see all your addresses. You have a couple of options here. You can choose not to print all of the addresses. This is in the Records option on the bottom left. If you want to test this with a single sheet, for instance, you can choose just the first XX addresses and test this out. On the bottom right, you can choose to save this as a File or send it directly to the Printer. Up to you. If you’re wary and don’t want to waste label sheets, this might be a good option. Or if you need to print these on a different printer, that would be helpful. But if you’re ready to print, select “OK” and you’ll get one more chance to change your mind because you’re finally going to see THE LABEL MERGE! (Woot! Rejoice!):

The screenshot above shows you the final window I get before I actually print the labels. And, assuming everything worked correctly, you’ll finally see the address information merged into the labels. Success!

This is not a simple process but there is, as with all things LibreOffice, a lot of customizability, which is why I prefer LO over Microsoft products.

Anyway, that’s how you do labels merge in LibreOffice. And, bonus, if you ever need to use that same address information in the future, it’s already registered in LibreOffice so you can just do this again. If not, you can delete it as I illustrated above.

 5,660 total views,  17 views today

R – Finding and Setting Working Directory

R, like many software programs, likes to have a folder or directory on your computer to operate in. When you start R, depending on how you start it and whether or not you previously saved your session, it’s likely that R will set a default “working directory” or folder where it is going to look for files and folders and where it will default to storing whatever it is you are working (e.g., script files, etc.). Many R beginners don’t know that you can change the working directory AND it is really useful to do so.

There are two ways to change your working directory if you are using R with RStudio – from the console or using the menus in RStudio. I’ll show them both.

To begin with, you can use the following code to get your current working directory:

getwd()

When you enter this into the console or run this from a script file, R will indicate what the current working directory is, like this:

In the screenshot above, you can see that I had set my working directory to a folder called “new analysis” for a project I am working on, but it also shows the entire folder hierarchy to my working directory: “/home/ryan/Dropbox/Ryan/writing/transing god/new analysis”. Knowing what my working directory is, makes it much easier to change to my working directory.

To change your working directory, you can copy the folder hierarchy that R provided and simply change it to the new location. So, for instance, if I wanted to change my working directory to a different project that is stored in a different folder, I can just change the folder hierarchy with the following command:

setwd("/home/ryan/Dropbox/Ryan/writing/futurism studies/data/")

Basically, getting your working directory uses the code “getwd()” with nothing in the parentheses, and setting your working directory uses the code “setwd(“/path/to/folder/”)” with the folder hierarchy included inside quotes inside the parentheses. This is how you get and set your working directory from the console.

If you’re using RStudio to interface with R, you can also set your working directory using the point-and-click menus. Click on Session -> Set Working Directory -> Choose Directory:

Once you click on “Choose Directory,” a window will pop up that will let you select the folder that you want to be your working directory:

Navigate to the folder you want to use as your working directory, select it, and hit “Open” and that will set your working directory. You should also see the corresponding code in the console that matches what we did above.

You can, of course, check to make sure that your working directory has changed by using the code above – “getwd()”. It should now be your new working directory.

Why might you want to change your working directory? The major advantage to doing this is that you no longer have to give the full path length to files you want to import, export, or work on. You can simply give the relative path based on the working directory. For instance, if I want to save a table of data from my environment, if I have set my working directory, I don’t have to specify the entire path to the file when I save it, I can simply save it to my working directory with the name, like this:

write.csv(MyData, file = "MyData.csv")

The code above will save the environment object “MyData” as a CSV file into my working directory and call it “MyData.csv”. If I haven’t set my working directory and want to save the same object, I would have to specify the directory where I want to save it, like this:

write.csv(MyData, file = "/home/ryan/Dropbox/writing/someproject/MyData.csv")

Setting your working directory also makes it easier to import files as you only have to use the name of the file you want to import and not the entire folder hierarchy to the file. With my working directory, I could import a CSV file like this:

dataframe1 <- read.csv("MyData.csv", header=TRUE)

Contrast that code with this code that would be required if I had not set my working directory:

dataframe1 <- read.csv("/home/ryan/Dropbox/writing/someproject/MyData.csv", header=TRUE)

Using a working directory saves time and makes it much easier to import and export files from R.

BONUS:

If you ever need to find your folder hierarchy, this is relatively easy to do on Linux or Windows (no promises on Mac). On Linux, just open a file manager (like Dolphin), navigate to the folder you want, then select the folder hierarchy in your file manager, like this:

You can simply copy and paste that into R. If you want to use the console to do it, you can also navigate to the folder in a console on Linux then use the “pwd” (path to working directory) command to get your current directory:

 1,257 total views,  3 views today

Launching HandBrake 1.4.0 in Kubuntu 21.04

The fine folks at HandBrake have updated their software and distribution system to a Flatpack approach. Their Flatpack for Linux is based on Gnome, not KDE, which is fine, but it does mean that the GUI is no longer skinned with my system settings on KDE. Oh well…

The bigger issue is that, with a flatpack install, HandBrake is no longer registered with the KDE system and has to be launched from the command line. That isn’t particularly onerous, but it is annoying when I use KDE’s KRunner to launch most of my software (Alt + F2). There is a solution to this that works just fine: add HandBrake to the Applications in the Application launcher.

To do this, right-click on the Application launcher and select “Edit Applications”:

In the window that comes up, select “New Item” to add HandBrake as an Application:

You’ll get a Window to name the new item:

You can then fill in the following details in the General tab:
Name: HandBrake
Description: HandBrake
Comment: launch Handbrake from Flatpack
Command: flatpack run fr.handbrake.ghb

If you want, you can also download the Handbrake logo and select it by clicking on the little square next to Name and Description:

When you’re done, hit “Save” and HandBrake will be registered with the system as an Application.

Now, when you use KRunner (Alt + F2), HandBrake will pop up as an option:

 1,308 total views,  1 views today

LibreOffice Calc – VLookup with dates

In a different post on this blog, I showed how to use Vlookup to match lists. Someone commented on that post and indicated that it didn’t work with dates. It turns out, it does, but… There is a slight tweak required to make it work. So, if you want to learn how to use VLookup, first go to that previous post. Then come back here to see how this works with dates.

The issue with dates has to do with the format of the cells. To illustrate this, I created a spreadsheet and inserted a bunch of dates:

It’s important to make clear at this point that LibreOffice Calc, just like other spreadsheet software, has different “formats” for cells. Cells can be formatted as numbers, as text, as dates, etc. This is important because LibreOffice will treat cells with different formats differently. For instance, it’s pretty challenging to do numerical calculations with text (e.g., “apple” + 65 = ?). LibreOffice needs to know the “format” of a cell. That is the key to making vlookup work with dates.

To check the format of a cell, all you need to do is right-click on it and select “Format Cells” (or Format -> Cells from the menus at the top of the screen):

Obviously, if you’re working with dates, then the format for the cells should be “Date” and whatever specific date format you want:

Okay, back to vlookup. To find a date in a list of dates, the value you are searching for also has to be a date in the Date format – ideally, they should be formatted identically. You can see in this spreadsheet, I inserted a date to search for in my list of dates:

The vlookup formula isn’t any different. In the cell just to the right of where I inserted the date I want to search for, I added my vlookup formula. Here’s what I put into my formula:

=VLOOKUP(E1,A1:A22,1,0)

This formula calls the “vlookup” function. “E1” is the date for which we are going to search in the list of dates. “A1:A22” is the list of dates in which we are searching. The “1” after that says to use the first item in the list of items we are searching for (kind of a weird requirement). And the “0” tells LibreOffice Calc that the list is not alphabetized or sorted.

Once I put that formula in, LibreOffice Calc will search through the list to see if my date is in the list. I know that my date is there. And, typically, vlookup will return the matching date if it is there, so it should return “8/27/2021”. But, here’s what I get when I hit return on my formula:

Rather than getting the target date, I get a weird number: 44435. Knowing a little bit about LibreOffice Calc, I quickly realized what the problem is: LibreOffice Calc doesn’t know that I’m searching for a date. It found the date, but the field where it is returning the value it found is currently formatted as a “Number,” not a “Date.” See:

To show that it found the matching date, the vlookup cell also needs to be formatted as a Date. So, change the formatting for the vlookup cell:

And once you hit OK, you should now see the date it found:

In short, yes, vlookup works with Dates. You just have to make sure that the cells where the vlookup formula is located are formatted as Dates not as Numbers and you’ll see which Dates match.

 1,690 total views,  1 views today

R – changing mirror in RStudio

CRAN (The Comprehensive R Archive Network) is a distributed set of servers that allow people to download the various R packages from a bunch of servers that are all “mirrors” of each other. These servers or mirrors are called “repositories.” There are many advantages to this: (1) people can download from a mirror that is closer to them which should result in a faster download and (2) if a server or mirror goes down, you can switch to one that is still up.

If you ever find yourself in the situation that you are unable to update a package because CRAN is down, there is a quick and easy way to change the server you use for downloading packages.

In RStudio, click on Tools -> Global Options:

In the window that comes up, look for “Packages” on the left hand side:

To change the repository, click on “Change” and select a different location:

When you’re done, select “OK” and “OK” again. You can then try updating your packages or downloading new packages again. Assuming that mirror is up and running, that should solve your problem.

 1,139 total views,  5 views today