Using R in Power BI to check if file exist

I have done a series of blog posts on how R can be used in Power BI. I have also created quick videos for each of those posts and I will do the same for this post. I find it easier and more efficient to share this information via video than through a narrative with screenshots. In this blog post, I’m going to share the code that can be used to check if a file exist prior to processing of that file. I will record a video that goes in more depth and include that in the blog post later.

Check if file exist

As someone who comes from an enterprise BI background, I am always looking for ways to handle things I would have previously done with SSIS. With R integration we have a lot of new possibilities.

The Code:

fileexists <- FALSE
fileName   <- “C:\\Backup\\Blogs\\R – Check if File Exist\\CustomerSales1.csv

while (fileexists == FALSE)
    {
   #fileexists = TRUE ##Test Expression
   fileexists <-
            if(
                file.exists(fileName))
               {TRUE} else {FALSE}
   print(fileexists)
   ## Add 3 second Delay
   Sys.sleep(3)   
    }
   
    data  = read.csv(fileName)
    head(data)

Advertisement

PASS Summit–Lightning Talk on R

I’m excited to have the opportunity to speak at PASS Summit 2018. I am doing a quick 10 minute lightning talk on R integration with Power BI. Somehow I was able to sneak in with this incredible group of speakers! SHHHHH, don’t tell anyone lest they find out!

Speakers

I have loaded my slide deck here, this includes what you need to get started with R! Slide Deck

In this talk I am focusing on how R can be used to extend the capabilities and functionality of Power BI. More specifically, I will be using R to show the following four demos:

  • How to extract data from Power BI using R
  • How to unzip and process files with R
  • How to Download, unzip and process files
  • How to check if file exist before processing the file

Also, I have created blog posts with corresponding YouTube videos already on 3 of the 4 demos listed above!

YouTube

My YouTube channel is simply MitchellSQL

Blog: MitchellPearson.com

Below are the three blog posts that I have previously posted:

Export Data from Power BI using R

Unzip and Process files into Power BI with R

Download, unzip, and process with R

Using a Journal

In this blog, I’m going to introduce you to my personal journaling method. I have, over time, developed a journaling technique that works great for me. I began my journal experience by scribbling aimlessly in journals with no form of organization. Eventually I was introduced to a journal technique called bullet journaling. I started initially with this technique and over time made many adjustments that have grown to fit me very well.

This blog post is broken down into many sections with smaller sections.

  • What’s in my journal
  • Why do I have a journal
  • How do I set up my journal

Part 1 – What’s in my Journal

So what’s in my journal? Glad you asked Smile, at a high level my journal contains checklists, goals, tasks, ideas, stories, quotes, notes and much more from virtually every aspect of my life. Yes, you read that right. Somehow, I have created a journal that allows me to store information about my work, family, faith, personal development and everything in between into a single journal.

My journal is a checklist, it keeps me on track and focused on specific goals. It’s also a diary. I keep track of successes and failures. I track stories of friends and families. I also include contacts that I meet, mistakes that I make, processes that I feel can be improved.

In the back of my journal I have an area called Brain Dump, this is where I dump ideas and thoughts and to do list items that pop in my head. I also have an index, organized categorically, that helps me quickly find items stored in my journal, this is the latest addition to my journal method and one I’m very excited about.

Part 2 – So why do I journal?

I journal because I want to remember, I want learn, I want to grow and improve and become better in virtually every aspect of my life.

I want to remember stories of my children growing up, good times that I have with family and friends. I want to remember people I meet, I want to remember details that they shared with me, I want to remember the sad times and the tough times so I can appreciate the good times and use persevere through difficult times.

I want to learn, grow, improve, and become better in virtually every aspect of my life. The journal gives me an opportunity to record a written record of my life. If I have successes I record those so I can try to duplicate those efforts, likewise if I experience failure or make mistakes then I record those so I can use my past as a learning experience to grow from.

Jim Rohn encourages journaling for many reasons, he especially encourages one to record their mistakes:

“Mistakes in judgement are nothing to be ashamed of, surely most of our personal growth comes as a result of our errors. But what is truly unforgivable is to make the same mistake twice, every mistake has its’ own price tag. But the most costly error anyone can make is an error unlearned and often repeated.” – Jim Rohn

The process of reflection and refinement

I have found the most valuable part of keeping a journal is not recording a history of events, no, I have found that the most valuable part of keeping a journal is going back over a day, a week, a month and reflecting on those events. I reflect on mistakes and remember what those mistakes felt like and try to make sure that I make the necessary changes to not repeat those mistakes. I reflect on my successes and look for ways to improve those processes, I reflect on my failures and, likewise, improve the process to verify those failures don’t occur again.

This is an eye-opening process and one that has helped me to evaluate and redefine even the most mundane of activities on a weekly basis.

  • I no longer take coffee or water on the plane. Having these uncovered drinks disrupts the process of doing work and so I opt for always carrying water on the plane with me.
  • I no longer turn down the air when I enter a hotel room. I have discovered that I personally am much less motivated to get work done when the hotel room is cold!
  • I have removed all games from my phone.
  • I schedule high-priority tasks during high-energy parts of my day and I schedule meetings at lower, less efficient parts of my day.
  • I now regularly sit in the back of the car when the family is commuting across town, this allows significant time with the kids.

This is a tiny list of modifications I have made in my day to day life and are literally items that came to mind as I was writing this blog. I have a lot of other things that are being recalled to memory at this very moment, the process of reflection can not be underestimated!

Part 3 – The Setup!

I’m very excited about the way I set up and configure my journal, the best way to see this is by watching, take a look at the following video:

https://youtu.be/9cpjLzqnOME