To extract CSV and JSON files while using Google Colab and Google Drive, you can follow these steps:
Step 1: Mount your Google Drive
In Google Colab, run the following command to mount your Google Drive:
``code
from google.colab import drive
drive.mount('/content/gdrive')
```
Follow the prompts to authenticate and authorize access to your Google Drive.
*Step 2: Access your files*
Once your Google Drive is mounted, you can access your files using the `!ls` command:
```bash
!ls /content/gdrive/MyDrive/
```
Replace `MyDrive` with the name of the folder that contains your CSV and JSON files.
Step 3: Extract CSV files
To extract a CSV file, use the `!cp` command:
```
shell
!cp /content/gdrive/MyDrive/file.csv /content/
```
Replace `file.csv` with the name of your CSV file.
Step 4: Extract JSON files
To extract a JSON file, use the `!cp` command:
```
shell
!cp /content/gdrive/MyDrive/file.json /content/
```
Replace `file.json` with the name of your JSON file.
Step 5: Load the files into your Colab notebook
To load the extracted CSV file into a Pandas dataframe:
```
import pandas as pd
df = pd.read_csv('file.csv')
```
To load the extracted JSON file into a Python dictionary:
```
import json
with open('file.json', 'r') as f:
data = json.load(f)
```
Now you can work with your CSV and JSON files directly in your Google Colab notebook!