Project 1: Import/Export Script
Import file created from Baselight (Baselight_export.txt)
Import Xytech work order (Xytech.txt)
The script will parse data.
Computation is done to match shareholder requests, to replace the file system from local Baselight to facility storage (remember color correctors prefer local storage for bandwidth issues).
Remember, we are dealing with 3rd party data, so some errors in the data might occur, and you have to deal with it.
Export CSV file ('/' indicates columns):
Line 1: Producer / Operator / Job / Notes
Line 4: Show Location / Frames to Fix
Frames and frame ranges processed in consecutive/numerical order shown (from Baselight_export.txt) as either:
ranges (i.e. /filesystem/Dune2/PartA/1920x1080 32-35)
individually (i.e. /filesystem/Dune2/PartA/1920x1080 41)
Frames shown need to reflect their proper location and not mix with ranges from another location.
import csv
import re
print("Current files: ")
print('------------------------------------------------------------')
# parsing two files, computationally two things frame ranges and folder fix and exporting CSV files
# method import and read Baselight file
with open('Baselight_export.txt', 'r') as file:
baselight_data = []
Baselight_data = file.read()
print(Baselight_data)
# method to import and read Xytech file
with open('Xytech.txt', 'r') as file:
xytech_data = []
Xytech_data = file.read()
print(Xytech_data)
print('------------------------------------------------------------')
# Function to parse Baselight.txt
def parse_baselight_data():
data = {}
with open("Baselight_export.txt", 'r') as file:
lines = file.readline()
current_location = None
for line in lines:
line = line.strip()
if line.startswith("/baselightfilesystem1"):
current_location = line
data[current_location] = []
else:
frames = re.findall(r'd+', line)
data[current_location] = []
return data
# Function to parse Xytech.txt
def parse_xytech_data(data):
parsed_data = []
for line in data:
parsed_line = line.split(',')
# parsed_line = line.split[0]
show_location = parsed_line[0]
frames_fix = parsed_line[1]
parsed_data.append({'Show Location': show_location, 'Frames to Fix': frames_fix})
return parsed_data
# Function to compute frame ranges
def compute_frames(data):
for line in data:
frames_fix = line.get('Frames to fix')
if frames_fix:
ranges = re.findall(r'/d+-d+-', ''.join(frames_fix))
if ranges:
line['Frames Ranges'] = ranges
# Combine data and compute frame ranges
combined_data = baselight_data + xytech_data
print('Combined data: ', combined_data)
compute_frames(combined_data)
print('Computed data: ', combined_data)
# Parse Baselight data
parse_baselight_data = parse_baselight_data()
print('Parsed Baselight data: ', parse_baselight_data)
# Parse Xytech data
parse_xytech_data = parse_xytech_data(xytech_data)
print('Parsed Xytech data: ', parse_xytech_data)
# Export to CSV
with open("baselight_and_xytech.csv", 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Producer', 'Operator', 'Job', 'Notes'])
writer.writerow([' '])
writer.writerow([' '])
writer.writerow(['Show Location', 'Frame to fix'])
for row in combined_data:
writer.writerow([
row.get('Producer', ''),
row.get('Operator', ''),
row.get('Job', ''),
row.get('Notes', ''),
row.get('Show Location'),
row.get('Frames Fix'),
writer.writerow([' ']),
writer.writerow([' ']),
writer.writerow([' ']),
writer.writerow([' ']),
row.get('Frames Ranges', ''),
', '.join(map(str, row.get('Frames fix', []))),
', '.join(map(str, row.get('Frames Ranges', [])))
])Project: Example with Random Data
Xytech: /ddnsan2/avengers/reel1/1920x1080
Baselight_export:
/images1/avengers/reel1/1920x108010111213192324
/ddnsan2/avengers/reel1/1920x1080 10-13
/ddnsan2/avengers/reel1/1920x1080 19
/ddnsan2/avengers/reel1/1920x1080 23-24
WHAT IS WRONG WITH MY CODE I CAN'T GET IT TO WORK
Project: Example with Random Data
Xytech: /ddnsan2/avengers/reel1/192ox1o8o
Baselight_export:
/ddnsan2/avengers/reel1/192ox1o8o
10-13
/ddnsan2/avengers/reel1/192ox1o8o
19
/ddnsan2/avengers/reel1/192ox1o8o
23-24