File size: 1,258 Bytes
c391a07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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 <<EOF >> "$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"