-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcat_image_quality_surveys.py
49 lines (35 loc) · 1.6 KB
/
concat_image_quality_surveys.py
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
47
48
49
import os
import pandas as pd
import argparse
# python concat_image_quality_surveys.py -i R:\IMAS\Antarctic_Seafloor\image_quality_analysis
def get_parser():
parser = argparse.ArgumentParser(add_help=False)
# MANDATORY ARGUMENTS
mandatory_args = parser.add_argument_group('MANDATORY ARGUMENTS')
mandatory_args.add_argument('-i', '--ifolder', required=True, type=str,
help='Input folder containing all surveys.')
# OPTIONAL ARGUMENTS
optional_args = parser.add_argument_group('OPTIONAL ARGUMENTS')
optional_args.add_argument('-r', '--rm', dest='rm', required=False, type=bool, default=False,
help='If False, only surveys with no existing results will be processed. If True, all'
' surveys will be processed.')
optional_args.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS,
help='Shows function documentation.')
return parser
def concat_image_quality_surveys(input_folder):
lst_df = []
for f in os.listdir(input_folder):
if f.endswith(".csv") and f.startswith("results_"):
df = pd.read_csv(os.path.join(input_folder, f))
lst_df.append(df)
df_full = pd.concat(lst_df)
print(len(df_full))
fname_out = os.path.join(input_folder, "image_quality_score.csv")
df_full.to_csv(fname_out, index=False)
def main():
parser = get_parser()
args = parser.parse_args()
# Run function
concat_image_quality_surveys(input_folder=args.ifolder)
if __name__ == "__main__":
main()