This guide provides detailed instructions for setting up the Dataverse Bulk Metadata Update Tool.
- Python: 3.7 or higher
- Operating System: Windows, macOS, or Linux
- Disk Space: ~200MB for dependencies
- Internet: For Dataverse API access
# Option A: Clone with Git
git clone https://github.com/your-org/Update_FileMetadata_Dataverse_multipleDOIs.git
cd Update_FileMetadata_Dataverse_multipleDOIs
# Option B: Download ZIP
# Download from GitHub and extract
unzip Update_FileMetadata_Dataverse_multipleDOIs.zip
cd Update_FileMetadata_Dataverse_multipleDOIsCreating a virtual environment isolates project dependencies:
On macOS/Linux:
# Create virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate
# You should see (venv) in your terminal promptOn Windows:
# Create virtual environment
python -m venv venv
# Activate it
venv\Scripts\activate
# You should see (venv) in your terminal prompt# Upgrade pip first
pip install --upgrade pip
# Install required packages
pip install requests
# Verify installation
python -c "import requests; print(f'requests version: {requests.__version__}')"# Test Python version
python --version
# Should show: Python 3.7.x or higher
# Test imports
python -c "from utils import load_json_file; print('✓ Utils module loaded')"
# Test script availability
python json_to_csv.py --help
python csv_to_json.py --help
python dataverse_api.py --helpAfter installation, you should have:
Update_FileMetadata_Dataverse_multipleDOIs/
├── utils.py
├── json_to_csv.py
├── csv_to_json.py
├── dataverse_api.py
├── config.ini
├── README.md
├── WORKFLOW.md
├── INSTALLATION.md (this file)
├── data/
│ ├── json_templates/ # Your JSON files go here
│ ├── json_output/ # Generated JSON files
│ └── metadata.csv # CSV for editing
├── backups/ # Automatic backups
├── logs/ # Operation logs
└── venv/ # Virtual environment (if created)
Create the necessary directories:
# Create data directories if they don't exist
mkdir -p data/json_templates data/json_output
mkdir -p backups logs
# Verify
ls -la data/
# Should show: json_templates, json_output, metadata.csvEdit config.ini with your settings:
[dataverse]
server_url = https://your-dataverse-instance.org
api_token = ${DATAVERSE_API_TOKEN}Instead of hardcoding credentials, use environment variables:
On macOS/Linux:
# Add to ~/.bashrc or ~/.zshrc
export DATAVERSE_SERVER_URL="https://your-dataverse.org"
export DATAVERSE_API_TOKEN="your-secret-token"
# Apply changes
source ~/.bashrc # or ~/.zshrcOn Windows (Command Prompt):
setx DATAVERSE_SERVER_URL "https://your-dataverse.org"
setx DATAVERSE_API_TOKEN "your-secret-token"
# Restart Command Prompt for changes to take effectOn Windows (PowerShell):
$env:DATAVERSE_SERVER_URL = "https://your-dataverse.org"
$env:DATAVERSE_API_TOKEN = "your-secret-token"
# To make permanent, use:
[Environment]::SetEnvironmentVariable("DATAVERSE_SERVER_URL", "your-value", "User")# Check environment variables are set
echo $DATAVERSE_SERVER_URL
echo $DATAVERSE_API_TOKEN
# Test connection
python dataverse_api.py --help-
Go to your Dataverse instance
- Navigate to: https://your-dataverse.org
-
Log in to your account
- Click on your profile icon (top right)
- Select "Account"
-
Generate API Token
- Look for "Create API Token" button
- Click to generate
- Copy the token immediately and save securely
-
Store securely
- Never commit to version control
- Use environment variables only
- Treat like a password
Solution:
# Check if Python is installed
which python3
# or
python --version
# If not installed:
# macOS: brew install python3
# Linux: sudo apt-get install python3
# Windows: Download from python.orgSolution:
# Ensure virtual environment is activated
source venv/bin/activate # macOS/Linux
# or
venv\Scripts\activate # Windows
# Reinstall dependencies
pip install --upgrade pip
pip install requests
# Verify
pip listSolution:
# On macOS/Linux, use sudo (not recommended, but sometimes needed)
sudo pip install requests
# Better: Fix permissions
sudo chown -R $USER /usr/local/lib/python3.x/site-packages/
# Or use the --user flag
pip install --user requestsSolution:
# Make sure virtual environment is activated
source venv/bin/activate
# Install requests
pip install requests
# Verify it's installed
python -c "import requests; print('OK')"After installation, verify everything works:
- Python 3.7+ installed:
python --version - Virtual environment created:
ls -la venv/ - Virtual environment activated:
(venv)shows in prompt - Dependencies installed:
pip list | grep requests - Directories created:
ls -la data/ - Test scripts run:
python json_to_csv.py --help - Sample data exists:
ls -la data/json_templates/ - Dataverse server accessible:
curl -s https://your-dataverse.org/api/v1/info/version
Run a quick test to verify everything:
# 1. Activate environment
source venv/bin/activate
# 2. Convert JSON to CSV
python json_to_csv.py \
--input-dir ./data/json_templates \
--output-csv ./data/test_metadata.csv
# 3. Check output
head data/test_metadata.csv
# 4. Convert back to JSON
python csv_to_json.py \
--csv-file ./data/test_metadata.csv \
--output-dir ./data/test_json_output
# 5. Verify output
ls -la data/test_json_output/
cat data/test_json_output/doi_*.json | python -m json.tool | head -20Expected output:
✓ Successfully converted X rows to ./data/test_metadata.csv
✓ Created: ./data/test_json_output/doi_*.json
✓ Successfully converted X JSON files to ./data/test_json_output
For containerized deployment:
# Dockerfile
FROM python:3.9-slim
WORKDIR /app
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy project
COPY . .
# Install Python dependencies
RUN pip install --no-cache-dir requests
# Create necessary directories
RUN mkdir -p data/json_templates data/json_output backups logs
CMD ["/bin/bash"]Build and run:
# Build image
docker build -t dataverse-bulk-update .
# Run container
docker run -it -v $(pwd)/data:/app/data dataverse-bulk-update
# Inside container
python json_to_csv.py --helpFor contributing or development:
# Install additional development dependencies
pip install pytest pytest-cov black flake8
# Run tests
pytest
# Format code
black .
# Check code style
flake8 .# Update all packages
pip install --upgrade pip
# Reinstall dependencies
pip install --upgrade requests
# Check for outdated packages
pip list --outdated# Remove virtual environment
rm -rf venv/
# Remove the entire project directory
rm -rf Update_FileMetadata_Dataverse_multipleDOIs/After successful installation:
- Read the README:
cat README.md - Review WORKFLOW.md:
cat WORKFLOW.md - Place JSON files: Put your JSON templates in
data/json_templates/ - Test conversion: Run
python json_to_csv.py --help - Set up credentials: Add Dataverse API token to environment variables
- Run first conversion: Follow the Quick Start guide in README.md
For issues:
- Check that Python version is 3.7+
- Verify virtual environment is activated
- Ensure
requestsis installed:pip install requests - Check environment variables are set:
echo $DATAVERSE_API_TOKEN - Verify JSON files are in correct location
- Review error messages in
logs/directory
- Python Documentation: https://docs.python.org/3/
- Requests Library: https://docs.requests.org/
- Dataverse API Docs: https://guides.dataverse.org/en/latest/api/