LEVY FILE.txt Flashcards
Required= Python installed & visual studio code
- Copy & paste ‘’5 and 7 character ULN import’’ into another notepad & save it as”: create_levy_file.py = save the file
- Open visual studio code, click file & new file, click and drag ‘’create_levy_file.py’’ to the visual studio code window
- Click file save as the same name & replace by clicking ‘’yes’’
- Type ‘’IDLE’’ into search bar for IDLE Python
- Click ‘’file’’ then click ‘’open’’, find your saved ‘’ create_levy_file.py’’ file
- RUN & RUN + F5, input all info and type ‘’NO’’ when done
LASTLY INPUT ALL INFORMATION CAREFULLY!!! NO MISTAKES
7 character ULN import.txt
——————————–>
import os
HEADER = “ADVK000U0.LVY202104200101000375MBYWG0000SCOTT\n”
def get_user_input():
“"”Prompt user for input and return a dictionary of the input values.”””
data = {}
data[‘UTC’] = input(“Enter UTC: “)
data[‘ULN’] = input(“Enter ULN: “)
data[‘Line number’] = input(“Enter Line number: “)
data[‘AFSC’] = input(“Enter AFSC: “)
data[‘UIC’] = input(“Enter UIC: “)
return data
def format_to_levy(data):
“””
Format the input data to match the levy file’s required format and spacing:
- Add ‘0’ between UTC and ULN
- Add “00” after 5-character ULN to make it 7 characters long
- Maintain appropriate spacing between special cases
“””
utc = data[‘UTC’]
uln = data[‘ULN’]
# Ensure the ULN is 7 characters for both 5 and 7 characters ULNs if len(uln) == 5: uln += "00" # Pad with "00" if ULN is 5 characters long line_number = data['Line number'] afsc = data['AFSC'] uic = data['UIC'] # Building the formatted line according to expected structure formatted_data = f"L{utc}0{uln}{' ' * 4}{line_number}{' ' * 2}{afsc}{' ' * 7}{uic}\n" return formatted_data
def write_to_file(formatted_data, filename):
“"”Append the formatted data to a file.”””
with open(filename, “a”) as file: # Open the file in append mode
file.write(formatted_data)
def main():
filename = “levy_file.txt” # Change file extension if necessary
if os.path.exists(filename):
os.remove(filename) # Delete existing file if present
# Write the header at the top of the file with open(filename, "w") as file: # Open the file in write mode file.write(HEADER) while True: user_data = get_user_input() formatted_data = format_to_levy(user_data) write_to_file(formatted_data, filename) print(f"Data successfully written to {filename}") # Check if the user wants to add another entry continue_input = input("Do you want to add another entry? (yes/no): ").strip().lower() if continue_input != 'yes': break
if __name__ == “__main__”:
main()
5 & 7 character ULN import.txt
——————————–>
import os
HEADER = “ADVK000U0.LVY202104200101000375MBYWG0000SCOTT\n”
def get_user_input():
“"”Prompt user for input and return a dictionary of the input values.”””
data = {}
data[‘UTC’] = input(“Enter UTC: “)
data[‘ULN’] = input(“Enter ULN: “)
data[‘Line number’] = input(“Enter Line number: “)
data[‘AFSC’] = input(“Enter AFSC: “)
data[‘UIC’] = input(“Enter UIC: “)
return data
def format_to_levy(data):
“””
Format the input data to match the levy file’s required format and spacing:
- Add ‘0’ between UTC and ULN
- Add 6 spaces after 5-character ULN
- Add 4 spaces after 7-character ULN
- Maintain spacing between other fields
“””
utc = data[‘UTC’]
uln = data[‘ULN’]
# Determine the appropriate number of spaces after ULN based on its length if len(uln) == 5: post_uln_spacing = ' ' * 6 # 6 spaces for 5-character ULN elif len(uln) == 7: post_uln_spacing = ' ' * 4 # 4 spaces for 7-character ULN else: raise ValueError("ULN must be either 5 or 7 characters long.") line_number = data['Line number'] afsc = data['AFSC'] uic = data['UIC'] # Construct the formatted line ensuring consistent spacing formatted_data = f"L{utc}0{uln}{post_uln_spacing}{line_number}{' ' * 2}{afsc}{' ' * 7}{uic}\n" return formatted_data
def write_to_file(formatted_data, filename):
“"”Append the formatted data to a file.”””
with open(filename, “a”) as file: # Open the file in append mode
file.write(formatted_data)
def main():
filename = “levy_file.txt” # Change file extension if necessary
if os.path.exists(filename):
os.remove(filename) # Delete the existing file if present
# Write the header at the top of the file with open(filename, "w") as file: # Open the file in write mode file.write(HEADER) while True: user_data = get_user_input() formatted_data = format_to_levy(user_data) write_to_file(formatted_data, filename) print(f"Data successfully written to {filename}") # Check if the user wants to add another entry continue_input = input("Do you want to add another entry? (yes/no): ").strip().lower() if continue_input != 'yes': break
if __name__ == “__main__”:
main()
RESOLUTION ALL DIGITS MACRO *PLEASE USE THIS ONE
import os
HEADER = “ADVK000U0.LVY202104200101000375MBYWG0000SCOTT\n”
def get_user_input():
“"”Prompt user for input and return a dictionary of the input values.”””
data = {}
data[‘UTC’] = input(“Enter UTC: “)
data[‘ULN’] = input(“Enter ULN: “)
data[‘Line number’] = input(“Enter Line number: “)
data[‘AFSC’] = input(“Enter AFSC: “)
data[‘UIC’] = input(“Enter UIC: “)
return data
def format_to_levy(data):
“””
Format the input data to match the levy file’s required format and spacing:
- Add ‘0’ between UTC and ULN
- Add 6 spaces after 5-character ULN
- Add 4 spaces after 7-character ULN
- Maintain spacing between other fields
- Ensure 6 spaces before UIC if AFSC is 6 characters long
“””
utc = data[‘UTC’]
uln = data[‘ULN’]
# Determine the appropriate number of spaces after ULN based on its length if len(uln) == 5: post_uln_spacing = ' ' * 6 # 6 spaces for 5-character ULN elif len(uln) == 7: post_uln_spacing = ' ' * 4 # 4 spaces for 7-character ULN else: raise ValueError("ULN must be either 5 or 7 characters long.") line_number = data['Line number'] afsc = data['AFSC'] # Determine the appropriate number of spaces before UIC based on AFSC length if len(afsc) == 6: pre_uic_spacing = ' ' * 6 # 6 spaces if AFSC is 6 characters long else: pre_uic_spacing = ' ' * 7 # 7 spaces otherwise uic = data['UIC'] # Construct the formatted line ensuring consistent spacing formatted_data = f"L{utc}0{uln}{post_uln_spacing}{line_number}{' ' * 2}{afsc}{pre_uic_spacing}{uic}\n" return formatted_data
def write_to_file(formatted_data, filename):
“"”Append the formatted data to a file.”””
with open(filename, “a”) as file: # Open the file in append mode
file.write(formatted_data)
def main():
filename = “levy_file.txt” # Change file extension if necessary
if os.path.exists(filename):
os.remove(filename) # Delete the existing file if present
# Write the header at the top of the file with open(filename, "w") as file: # Open the file in write mode file.write(HEADER) while True: user_data = get_user_input() try: formatted_data = format_to_levy(user_data) write_to_file(formatted_data, filename) print(f"Data successfully written to {filename}") except ValueError as e: print(e) # Check if the user wants to add another entry continue_input = input("Do you want to add another entry? (yes/no): ").strip().lower() if continue_input != 'yes': break
if __name__ == “__main__”:
main()