#!/usr/bin/env bash INPUT_FILE="sustainability_social_media_posts.csv" OUTPUT_FILE="unsloth_dataset.jsonl" # Remove old output rm -f "$OUTPUT_FILE" # Read CSV (skip header) tail -n +2 "$INPUT_FILE" | while IFS=',' read -r \ post_id \ user_id \ username \ post_date \ platform \ hashtag \ post_text \ engagement_likes \ engagement_shares \ engagement_comments \ user_followers \ user_location \ post_sentiment \ climate_topic \ call_to_action do # Escape quotes in text fields post_text_escaped=$(echo "$post_text" | sed 's/"/\\"/g') platform_escaped=$(echo "$platform" | sed 's/"/\\"/g') hashtag_escaped=$(echo "$hashtag" | sed 's/"/\\"/g') topic_escaped=$(echo "$climate_topic" | sed 's/"/\\"/g') sentiment_escaped=$(echo "$post_sentiment" | sed 's/"/\\"/g') cta_escaped=$(echo "$call_to_action" | sed 's/"/\\"/g') location_escaped=$(echo "$user_location" | sed 's/"/\\"/g') # Build JSON line cat <> "$OUTPUT_FILE" {"instruction": "Generate a climate-focused social media post.", "input": "Platform: $platform_escaped\nHashtag: $hashtag_escaped\nTopic: $topic_escaped\nSentiment: $sentiment_escaped\nCall to Action: $cta_escaped\nLocation: $location_escaped", "output": "$post_text_escaped"} EOF done echo "✅ Dataset generated: $OUTPUT_FILE"