<jupyter_start><jupyter_text>File Import/Export in Google Colab Uploading files from your local file system`files.upload` returns a dictionary of the files which were uploaded.The dictionary is keyed by the file name, the value is the data which was uploaded.<jupyter_code>from google.colab import files

uploaded = files.upload()

for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded[fn])))
ls<jupyter_output>[0m[01;34msample_data[0m/  state-abbrevs.csv<jupyter_text>Please note that any file that is being uploaded to Google Colab will not persist after the session is terminated (which is typically a 24-hour window). This should be used with caution. Downloading files to your local file system`files.download` will invoke a browser download of the file to the user's local computer.<jupyter_code>from google.colab import files

files.download('state-abbrevs.csv')<jupyter_output><empty_output><jupyter_text>Removing a file from the Colab containerWe can use the linux command `rm` to remove the file we just uploaded:<jupyter_code>rm state-abbrevs.csv<jupyter_output><empty_output><jupyter_text>We can check to see if the file was removed by listing the files in the current directory (`content`) by the linux command `ls`:<jupyter_code>ls<jupyter_output>[0m[01;34msample_data[0m/<jupyter_text>Manual upload/downloadThis can be done by clicking on the "Files" icon on the top left of your Colab notebook then "Upload".One can right click on any file to download it manually.**Note:** The working directory for Colab notebooks is "`content`" and we will only use that folder to avoid breaking anything.  Mounting Google Drive locallyThe example below shows how to mount your Google Drive in your virtual machine using an authorization code, and shows a couple of ways to write & read files there. Once executed, observe the new file (`foo.txt`) is visible in https://drive.google.com/Note this only supports reading and writing files; to programmatically change sharing settings etc use one of the other options below.<jupyter_code># Mount the drive
from google.colab import drive
drive.mount('/content/gdrive', force_remount=True)
ls gdrive/'My Drive'/_01_Teaching/BA780-Introduction-to-Data-Analytics-2020-Fall/tmp/Intro-to-Data-Analytics-main/data/<jupyter_output>2017_StPaul_MN_Real_Estate.csv  movies_ratings.csv
athlete_events.csv              state-abbrevs.csv
FremontBridge.csv               state-areas.csv
GOOGL.csv                       state-population.csv
GOT-battles.csv                 Telco-Customer-Churn.csv
GOT-character-deaths.csv        weatherHistory.csv
movies_metadata.csv<jupyter_text>I can now use this path (or any other path in My Drive) to store data that I would like to persist. For instance in the cell below I am copying sample_data/california_housing_train.csv to a folder of my choice in my Google Drive.<jupyter_code>cp sample_data/california_housing_train.csv gdrive/'My Drive'/_01_Teaching/BA780-Introduction-to-Data-Analytics-2020-Fall/tmp/Intro-to-Data-Analytics-main/data<jupyter_output><empty_output><jupyter_text>Let's confirm the file was copied properly. We can also go to Drive and visually inspect it:<jupyter_code>ls gdrive/'My Drive'/_01_Teaching/BA780-Introduction-to-Data-Analytics-2020-Fall/tmp/Intro-to-Data-Analytics-main/data<jupyter_output>2017_StPaul_MN_Real_Estate.csv  movies_metadata.csv
athlete_events.csv              movies_ratings.csv
california_housing_train.csv    state-abbrevs.csv
FremontBridge.csv               state-areas.csv
GOOGL.csv                       state-population.csv
GOT-battles.csv                 Telco-Customer-Churn.csv
GOT-character-deaths.csv        weatherHistory.csv<jupyter_text>Your Trun1. Go to https://grouplens.org/datasets/movielens/ and download `ml-latest-small.zip` file. Unzip it and then upload the following files to your Colab (`content` folder)  * movies.csv  * ratings.csv2. Mount Google Drive locally and copy these two files into a folder called `movie_rating` within your BA780 folder.  * You can use the following code example to copy movies.csv to a folder called tmp_BA780 (change it to your desired desitination)  ```cp movies.csv gdrive/My\ Drive/tmp_BA780```  * Notice that `gdrive/My\ Drive/` is your Drive's homepage.3. Check your Drive and make sure the files are there.4. Download these files to your local laptop.<jupyter_code># Your code goes here (please use as many cells as needed)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0775347912524851, 'fraction_numerical': 0.013695604152860615, 'mean_word_length': 4.61090458488228, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '112756', 'license': 'MIT', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1327, 'n_words': 468, 'path': '02-Data-Import-Export/02-File-Import-Export-in-Colab.ipynb', 'repo_name': 'nikkiii66/Intro-to-Data-Analytics', 'size': '4527'}