
Datasets and Storage Management
Learn how to manage data in Google AI Studio. Uploading CSVs for few-shot prompting, managing Google Drive files for long-context analysis, and handling temporary storage.
Datasets and Storage Management
AI applications run on data. Google AI Studio provides two main ways to handle data: Structured Prompts (CSV based) and Long Context File Uploads (Drive based).
1. Import for Structured Prompts
When you are using the "Structured Prompt" mode (Few-shot learning), manually typing 100 examples is painful.
- Feature: You can import a CSV or Google Sheet.
- Format: The sheet should have columns corresponding to your input/output variables (e.g., Column A: "CustomerReview", Column B: "Sentiment").
- Action: Click "Insert > Import from Sheets" in the prompt editor. This populates the few-shot examples automatically.
2. File Uploads for Context
For the 1M+ token window, you often want to upload a PDF or Video.
- Storage: When you hit the "+" button to add a file, it is uploaded to a temporary Google Generative AI File Store.
- Persistence: These files are temporary by default (often expiring after 48 hours if using the API directly without caching). In the Studio UI, they stay associated with your prompt until you delete them.
3. Google Drive Integration
Since it is a Google product, the integration with Drive is seamless.
- Grant Access: You can select a file directly from your Google Drive.
- Flow: Studio doesn't "download" the file to your laptop; it pulls it directly from Drive servers into the Gemini context. This is huge for 2GB video files.
API File Manager
If you are coding (Python SDK), you manage files programmatically:
import google.generativeai as genai
# Upload
sample_file = genai.upload_file(path="my_video.mp4", display_name="Project Video")
# Check State (Video takes time to process)
print(f"State: {sample_file.state.name}") # PROCESSING -> ACTIVE
# Use in prompt
model.generate_content(["Describe this video", sample_file])
# Cleanup
genai.delete_file(sample_file.name)
Summary
- Use CSV Import for training examples.
- Use File Upload for RAG-like context.
- Remember that API files are separate from your local disk and need lifecycle management (upload -> analyze -> delete).
In the next lesson, we will look at Notebook Integration—the data scientist's best friend.