Pinterest Stumbleupon Whatsapp
Ads by Google

import data into google spreadsheetWhen it comes to online databases and information that can be found inside what is commonly known as the “invisible web 10 Search Engines to Explore the Invisible Web 10 Search Engines to Explore the Invisible Web Read More “, I’m not your typical user. Sure, I spend a little bit too much of my time sifting through online databases at places like the National Archives and the CIA FOIA reading room, but I have to say nothing makes me more excited than when I find an HTML based table filled with volumes of seemingly complex and unconnected data.

The fact is, data tables are a goldmine of important truths. Data often gets collected by armies of data-collection grunts with boots on the ground. You’ve got people from the U.S. Census traveling the entire country for household and family information. You’ve got non-profit environmental groups collecting all sorts of interesting information about the environment, pollution, global warming and more. And if you’re into the paranormal or Ufology, there are also constantly updated tables of information about sightings of strange objects in the sky above us.

Ironically, you would think that any government in the world would be interested to know what sort of foreign craft are being spotted in the skies over any country, but apparently not – at least not in the U.S. anyway. In America, the collection of unusual sightings of crafts have been relegated to teams of amateur hobbyists who flock to new UFO sightings like moths to a flame. My interest in these sightings actually stems not from a fascination with aliens or crafts from other planets, but from a scientific fascination with patterns – where and why more people are seeing things in the sky, and whether those sightings could reflect something very real and much more down-to-Earth actually going on.

To explore the volumes of data collected by teams of UFO hobbyists, I’ve actually developed a way to import large HTML tables of data into a Google Spreadsheet, and then manipulate and analyze that data to extract and discover meaningful and important information. In this article, I intend to show you how to do the same.

Important HTML Data Into Google Spreadsheet

In this example, I’m going to show you how to import any data that might be stored in a table on any website on the Internet, into your Google Spreadsheet. Think about the enormous volume of data that’s available on the Internet today in the form of HTML tables. Wikipedia alone has data in tables for topics like global warming, the U.S. Census Bureau has tons of population datasets, and a little bit of Googling will land you a whole lot more beyond that.

In my example, I’m starting out with a database on the National UFO Reporting Center that actually looks like it might be a query-style deep-web database, but if you observe the URL structuring, it’s actually a semi-complex web-based reporting system consisting of static web pages and static HTML tables – exactly what we want when looking for data to import.
import data into google spreadsheet
NUForc.org is one of those organizations that serves as one of the biggest reporting centers for UFO sightings. It isn’t the only one, but it’s big enough to find new datasets with current sightings for every month. You choose to view the data sorted by criteria like State or Date, and each of those is provided in the form of a static page. If you sort by date and then click on the most recent date, you’ll see that the table listed there is a static web page named according to the date format.
import data into google docs
So, we now have a pattern to regularly extract the latest sightings information from this HTML-based database. All you have to do is import the first table, use the most recent entry (the top one) to identify the latest update, and then use the date of that posting to build the URL link where the latest HTML data table exists. Doing this will simply require a couple of instances of the ImportHTML function, and then a few creative uses of text manipulation functions. When you’re done, you’ll have one of the coolest, self-updating reporting spreadsheets of your very own. Let’s get started.

Ads by Google

Importing Tables and Manipulating Data

The first step, of course, is to create the new spreadsheet.
import data into google docs
So, how do you import HTML tables? All you need is the URL where the table is stored, and the number of the table on the page – usually the one first listed is 1, the second is 2, and so on. Since I know the URL of that first table listing dates and counts of sightings listed, it’s possible to import by typing the following function into cell A1.

=importhtml(“http://www.nuforc.org/webreports/ndxpost.html?”&H2,”table”,1)

H2 holds the function “=hour(now())“, so the table will update every hour. This is probably extreme for data that updates this infrequently, so I could probably get away with doing it daily. Anyway, the above ImportHTML function brings in the table as shown below.
UFOReport4
You’ll need to do a bit of data manipulation on this page before you can piece together the URL for the second table with all of the UFO sightings. But go ahead and create the second sheet on the workbook.
import data into google docs
Before trying to build that second sheet, it’s time to extract the post date from this first table, in order to build the link to the second table. The problem is that the date is brought in as a date format, not a string. So, first you need to use the TEXT function to convert the report post date into a string:

=text(A2,”mm/dd/yy”)

In the next cell to the right, you need to use the SPLIT function with the “/” delimiter to break the date up into month, day and year.

=split(D2,”/”)
import into google spreadsheet
Looking good! However, each number needs to be forced to two digits. You do this in the cells right below them using the TEXT command again.

=text(E2,”00″)

A format of “00” (those are zeroes) forces two digits, or a “0” as a placeholder.
import into google spreadsheet
Now you’re ready to rebuild the entire URL to the latest HTML table of new sightings. You can do this by using the CONCATENATE function, and piecing together all of the bits of information you just extracted from the first table.

=concatenate(“http://www.nuforc.org/webreports/ndxp”,G3,E3,F3,”.html”)
import into google spreadsheet
Now, on the new sheet you created above (the blank sheet), you’re going to do a new “importhtml” function, but this time for the first URL link parameter, so you’re going to navigate back to the first spreadsheet and click on the cell with the URL link you just created.
UFOReport9
The second parameter is “table” and the last is “1” (because the sightings table is the first and only on the page). Hit enter, and now you’ve just imported the entire volume of sightings that were posted on that particular date.
UFOReport10
So, you’re probably thinking this is a nice novelty act and everything – I mean, after all, what you’ve done is extracted existing information from a table on the Internet and migrated it to another table, albeit a private one in your Google Docs account. Yes, that’s true. However, now that it’s in your own private Google Docs account, you have at your fingertips the tools and functions to better analyze that data, and start discovering amazing connections.

Using Pivot Reports to Analyze Imported Data

Just recently, I wrote an article about using Pivot Reports in Google Spreadsheet Become An Expert Data Analyst Overnight Using Google Spreadsheet Report Tools Become An Expert Data Analyst Overnight Using Google Spreadsheet Report Tools Did you know that one of the greatest tools of all to conduct data analysis is actually Google Spreadsheet? The reason for this isn’t only because it can do nearly everything you might want to... Read More to perform all sorts of cool data analysis feats. Well, you can do the same amazing data analysis acrobatics on the data that you’ve imported from the Internet – giving you the ability to uncover interesting connections that possibly no one else has uncovered before you.

For example, from the final sightings table, I might decide to use a pivot report to take a look at the number of different unique shapes reported in each state, compared to the overall number of sightings in that particular state. Finally, I also filter out anything mentioning “aliens” in the comments section, to hopefully weed out some of the more wingnut entries.
UFOReport11
This actually reveals some pretty interesting things right off the bat, such as the fact that California clearly has the highest number of reported sightings of any other State, along with the distinction of reporting the highest number of craft shapes in the country. It also shows that Massachusetts, Florida and Illinois are big hitters in the UFO sightings department as well (at least in the most recent data).

Another cool thing about Google Spreadsheet is the wide array of charts available to you, including a Geo-Map that lets you lay out “hot spots” of data in a graphical format that really stands out and makes those connections within the data quite obvious.
import data into google spreadsheet
If you think about it, this is really only the tip of the iceberg. If you can now import data from data tables on any page on the Internet, just think of the possibilities. Get the latest stock numbers, or the most recent top 10 books and authors on the New York Times bestseller list, or the biggest selling cars in the world. There are HTML tables out there on almost any topic you can imagine, and in many cases those tables are frequently updated.

ImportHtml gives you the ability to plug your Google Spreadsheet into the Internet, and feed off the data that exists out there. It can become your own personal hub of information that you can use to manipulate and massage into a format that you can actually work with. It’s just one more very cool thing to love about Google Spreadsheet.

Have you ever imported data into your spreadsheets? What kind of interesting things did you discover in that data? How did you use the data? Share your experiences and ideas in the comments section below!

Image Credits: Business Graph

  1. Tereza
    November 23, 2016 at 11:41 am

    Hi! I am really unable to import the data, I would like to import it into excel worksheet. Do you, please, ave any idea how to do it? Thanks!

  2. Jonathan Yates
    June 10, 2016 at 4:57 pm

    I have followed your brilliant instructions and instead of pivot tables, I am using Tableau and the new google spreadsheet connector to analyse the data - check out Tableau Public, I'll past the link shortly its brilliant

  3. Ryan Dube
    November 3, 2013 at 6:44 am

    Great - thanks Andi. Glad the article helped. Do you know if Bigelow is still funding MUFON?

    • Andi
      November 3, 2013 at 10:34 pm

      I am not sure about who is funding MUFON, all I know is that their office moved close to where I work and that's how I met the owner. If I end up finding out I will let you know.

      I kept getting parse errors with the formula you used in the demo. Since I don't need the data to auto update, that this formula worked much better for me and all I had to do was change the date in the .html file and I was able to import a year's worth of data easy.

      =ImportHTML("http://www.nuforc.org/webreports/ndxe201210.html", "table", 1)

  4. Andi
    November 3, 2013 at 6:18 am

    Thank you soooo much for showing us how to do this! I am currently in an infographic course in graduate school and was interested in using this dataset for a project but I couldn't get the date/time to copy to Excel properly, because they were hyperlinks, they just populated as "#####". Your method solved that problem for me! Thank you!

    And on another note, I recently met the guy that runs the MUFON site, I will pass along the advice.

  5. Guy McDowell
    May 24, 2013 at 1:17 pm

    Wow. Powerful stuff! I knew you could do this sort of thing with MS Excel, but doing it with Google Spreadsheets is so much more portable. Whip that bad boy out at the next MUFON meeting. ;)

    I noticed Nisku, Alberta was on the list. That general area is home to many sightings and, I think, the RCAF's first official UFO report - if I remember correctly. It's also home to many cattle mutilation reports. You probably knew that though. I used to live near there.

    • Ryan Dube
      May 24, 2013 at 2:20 pm

      Yes - I'm actually always surprised to see just how many odd events (UFO sightings/disappearances/etc...) occur in Alaska. It's like paranormal central... :-)

      MUFON and other Ufology groups like that seem to be mostly made up of an aging membership, and so their technologies often seem lacking. I do think they could benefit from collaborating and pulling all of these different databases together.

  6. nash
    May 23, 2013 at 3:49 pm

    =importhtml(“http://www.nuforc.org/webreports/ndxpost.html?”&H2,”table”,1)

    gives

    #ERROR! - Parse error in the spreadsheet

    • Ryan Dube
      May 24, 2013 at 2:03 pm

      Strange, I didn't have that error. Try simple and go without the "?" at the end of the url, and remove the "&H2" just to see that it loads okay first. Then you can start playing around with trying to add parameters for hour/day/etc...

      • Nash
        May 24, 2013 at 3:04 pm

        =ImportHtml("http://nuforc.org/webreports/ndxevent.html?"&H2, "table", 1)

        This works.

        Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *