-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(!BREAKING): Group Manufacturers by Name, Fix Variant Typos (#19
) * Refactor compile_to_csv.py script - change spelling varients to variants, move manufacturers folders into alphabetical group folders * fix spelling for variant/variants in README.md, NB: resulting compiled CSV file - changed spelling for column is_varient to is_variant * Move manufacturers folders into alphabetical group folders; it was done with group_folders.sh bash script which is attached in scripts folders * update compile script to gracefully handle parsing errors, and fix some encoding issues --------- Co-authored-by: Roman Lazunin <[email protected]> Co-authored-by: Alex Toff <[email protected]>
- Loading branch information
1 parent
a44afb9
commit aa0f4f6
Showing
11,619 changed files
with
132 additions
and
69 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,105 @@ | ||
import os,csv,configparser | ||
|
||
outputcsv = "../build/ALL_DATA.csv"; | ||
readdir = "../src"; | ||
man_cols={"NAME":"manufacturer_name","COMPANY":"manufacturer_company"} | ||
type_cols={"MODEL":"model","ICAO":"icao","CLASS":"class","WAKE":"wake","ENG_TYPE":"engine_type","ENG_NUM":"engine_number","ENG_NAME":"engine_name","ENG_MAN":"engine_manufacturer","ENG_MODEL":"engine_model","ENG_THRUST":"engine_thrust","LENGTH":"length","WINGSPAN":"wingspan","TAIL_HEIGHT":"tail_height","RANGE":"range","CEILING":"ceiling","MAX_SPEED":"max_speed","PAX_CAP":"passenger_capacity","REMARKS":"remarks"} | ||
varient_cols={"BASE_MODEL":"base_model"} | ||
cols={**man_cols, **{"is_varient":'is_varient'}, **type_cols, **varient_cols} | ||
if os.path.exists(outputcsv): | ||
os.remove(outputcsv) | ||
csv_file = open(outputcsv,'w', newline='') | ||
writer = csv.writer(csv_file); | ||
writer.writerow(cols.values()) | ||
# Iterate Manufacturers | ||
for manu in os.listdir(readdir): | ||
config = configparser.ConfigParser() | ||
conf_file = open(readdir+"/"+manu+"/manufacturer.txt", 'r') | ||
config.read_string('[MANUFACTURER]\n'+conf_file.read()) | ||
config = config['MANUFACTURER'] | ||
man_insert = [config.get('name'),config.get('company')] | ||
print(config.get('name')) | ||
# Iterate Types | ||
for type in os.listdir(readdir+"/"+manu): | ||
row = [] | ||
if os.path.isfile(os.path.join(readdir+"/"+manu, type)): | ||
continue | ||
model_config = configparser.ConfigParser() | ||
model_conf_file = open(readdir+"/"+manu+"/"+type+"/"+type+".txt", 'r') | ||
model_config.read_string('[MODEL]\n'+model_conf_file.read().replace('%','%%')) | ||
model_config = model_config['MODEL'] | ||
model_insert =type_cols | ||
for key in type_cols: | ||
model_insert[key] = model_config.get(key, '') | ||
writer.writerow(man_insert+[0]+list(model_insert.values())) | ||
# Iterate Varients | ||
if os.path.exists(readdir+"/"+manu+"/"+type+"/Varients"): | ||
for varient in os.listdir(readdir+"/"+manu+"/"+type+"/Varients"): | ||
if os.path.isdir(readdir+"/"+manu+"/"+type+"/Varients/"+varient): | ||
continue | ||
varient_config = configparser.ConfigParser() | ||
varient_config.optionxform = str | ||
varient_conf_file = open(readdir+"/"+manu+"/"+type+"/Varients/"+varient, 'r') | ||
varient_config.read_string('[VARIENT]\n'+varient_conf_file.read()) | ||
varient_config = varient_config['VARIENT'] | ||
#varient_insert = varient_cols | ||
#for key in varient_cols: | ||
# varient_insert[key] = varient_config.get(key, '') | ||
varient_insert2 = model_insert.copy() | ||
for key in varient_config: | ||
if key in varient_insert2: | ||
varient_insert2[key] = varient_config[key] | ||
writer.writerow(man_insert+[1]+list({**varient_insert2, **{'BASE_MODEL':model_config.get('MODEL', type)}}.values())) | ||
varient_conf_file.close() | ||
|
||
model_conf_file.close() | ||
conf_file.close() | ||
print('-----------') | ||
file_dir = os.path.dirname(__file__) | ||
output_csv = os.path.join(file_dir, "../../build/ALL_DATA.csv") | ||
read_dir = os.path.join(file_dir, "../../src") | ||
|
||
man_cols = { | ||
"NAME": "manufacturer_name", | ||
"COMPANY": "manufacturer_company" | ||
} | ||
|
||
type_cols = { | ||
"MODEL": "model", | ||
"ICAO": "icao", | ||
"CLASS": "class", | ||
"WAKE": "wake", | ||
"ENG_TYPE": "engine_type", | ||
"ENG_NUM": "engine_number", | ||
"ENG_NAME": "engine_name", | ||
"ENG_MAN": "engine_manufacturer", | ||
"ENG_MODEL": "engine_model", | ||
"ENG_THRUST": "engine_thrust", | ||
"LENGTH": "length", | ||
"WINGSPAN": "wingspan", | ||
"TAIL_HEIGHT": "tail_height", | ||
"RANGE": "range", | ||
"CEILING": "ceiling", | ||
"MAX_SPEED": "max_speed", | ||
"PAX_CAP": "passenger_capacity", | ||
"REMARKS": "remarks" | ||
} | ||
|
||
variant_cols = {"BASE_MODEL": "base_model"} | ||
|
||
cols = {**man_cols, **{"is_variant": 'is_variant'}, **type_cols, **variant_cols} | ||
|
||
if os.path.exists(output_csv): | ||
os.remove(output_csv) | ||
|
||
csv_file = open(output_csv, 'w', newline='') | ||
|
||
writer = csv.writer(csv_file) | ||
writer.writerow(cols.values()) # write titles header row | ||
|
||
for group_dir in os.listdir(read_dir): # iterate high-level groups, like A, B, C etc. | ||
|
||
csv_file.close() | ||
for manufacturer in os.listdir(os.path.join(read_dir, group_dir)): # Iterate Manufacturers | ||
config = configparser.ConfigParser() | ||
|
||
manufacturer_dir = os.path.join(read_dir, group_dir, manufacturer) | ||
|
||
file_path = os.path.join(manufacturer_dir, "manufacturer.txt") | ||
with open(file_path, 'r') as file: | ||
try: | ||
config.read_string('[MANUFACTURER]\n' + file.read()) | ||
except Exception as error: | ||
print("Error whilst parsing " + os.path.abspath(file_path) + ": " + str(error)) | ||
exit() | ||
|
||
|
||
config = config['MANUFACTURER'] | ||
man_insert = [config.get('name'), config.get('company')] | ||
print(config.get('name')) | ||
|
||
# Iterate Types | ||
for aircraft_type in os.listdir(manufacturer_dir): | ||
|
||
if os.path.isfile(os.path.join(manufacturer_dir, aircraft_type)): | ||
continue | ||
model_config = configparser.ConfigParser() | ||
|
||
with open(os.path.join(manufacturer_dir, aircraft_type, aircraft_type + ".txt"), 'r') as file: | ||
model_config.read_string('[MODEL]\n' + file.read().replace('%','%%')) | ||
|
||
model_config = model_config['MODEL'] | ||
model_insert = type_cols | ||
|
||
for key in type_cols: | ||
model_insert[key] = model_config.get(key, '') | ||
|
||
writer.writerow(man_insert + [0] + list(model_insert.values())) | ||
|
||
# Iterate Variants | ||
variants_dir = os.path.join(manufacturer_dir, aircraft_type, "Variants") | ||
if os.path.exists(variants_dir): | ||
for variant in os.listdir(variants_dir): | ||
if os.path.isdir(os.path.join(variants_dir, variant)): | ||
continue | ||
|
||
variant_config = configparser.ConfigParser() | ||
variant_config.optionxform = str | ||
|
||
with open(os.path.join(variants_dir, variant), 'r') as file: | ||
variant_config.read_string('[VARIANT]\n' + file.read()) | ||
|
||
variant_config = variant_config['VARIANT'] | ||
|
||
variant_insert = model_insert.copy() | ||
for key in variant_config: | ||
if key in variant_insert: | ||
variant_insert[key] = variant_config[key] | ||
writer.writerow(man_insert + [1] + list({**variant_insert, **{'BASE_MODEL': model_config.get('MODEL', aircraft_type)}}.values())) | ||
print('-----------') | ||
|
||
csv_file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Define the directory where your subfolders are located | ||
BASE_DIR="../src" | ||
|
||
# Iterate through each subfolder in the base directory | ||
for dir in "$BASE_DIR"/*/; do | ||
# Get the first character of the directory name | ||
folder_name=$(basename "$dir") | ||
first_char="${folder_name:0:1}" | ||
|
||
# Create the destination parent directory based on the first character | ||
DEST_DIR="$BASE_DIR/$first_char" | ||
mkdir -p "$DEST_DIR" | ||
|
||
# Move the subfolder to the new parent directory | ||
mv "$dir" "$DEST_DIR" | ||
done |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.