File size: 924 Bytes
1d52f1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import os

# Directory containing the JSON files
directory = 'DemoFeedback'

# Check each file in the directory
for filename in os.listdir(directory):
    if filename.endswith('.json'):
        file_path = os.path.join(directory, filename)
        
        # Open and load the JSON file
        with open(file_path, 'r+') as file:
            data = json.load(file)
            
            # Check if 'revision' field is missing
            if 'revision' not in data:
                data['revision'] = 'N/A'
                
                # Move the file pointer to the beginning of the file
                file.seek(0)
                # Write the updated data
                json.dump(data, file, indent=4)
                # Truncate the file to the new data length
                file.truncate()
                print(f"Updated file: {filename}")

print("Files have been checked and updated as needed.")