File size: 1,358 Bytes
0dcc91f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
import pandas as pd
import json

# Load data from TSV file
df = pd.read_csv('MYP_Key_Related_Concepts.tsv', sep='\t')

# Print the column names
print(df.columns)

# Print the first few rows of the DataFrame
print(df.head())

# # Load data from TSV file
# df = pd.read_csv('MYP_Key_Related_Concepts.tsv', sep='\t')

# Initialize list to hold subject data
subjects = []

# Iterate over rows in DataFrame
for index, row in df.iterrows():
    subject = {}
    subject['Subject Name'] = row['Subject']
    
    # Get key and related concepts from row
    subject['Key Concepts'] = [v for k, v in row.items() if 'Key' in k and pd.notna(v)]
    subject['Related Concepts'] = [v for k, v in row.items() if 'Related' in k and pd.notna(v)]
    
    # Placeholder for aims and criteria
    subject['Aims'] = 'Aim text goes here...'
    subject['Criteria'] = [
        {
            'Criterion': f'Criterion {i+1}',
            'Strands': [f'Strand {j+1}' for j in range(5)]  # change range depending on number of strands
        } for i in range(4)  # change range depending on number of criteria
    ]
    
    # Append subject to subjects list
    subjects.append(subject)

# Combine all subjects into final dictionary
data = {'MYP Subjects': subjects}

# Write data to JSON file
with open('MYP_Subjects.json', 'w') as outfile:
    json.dump(data, outfile, indent=4)