-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge_csv.py
81 lines (55 loc) · 1.71 KB
/
merge_csv.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Merge CSV Files.
This script reads contents from different CSV files and merges them in one CSV
file.
Revision History:
2020-07-12 (Animesh): Baseline Software.
Example:
$ python folder_to_csv.py
"""
#___Import Modules:
import pandas as pd
from sklearn.utils import shuffle
#___Global Variables:
# FILE = ["data/lists/NORMAL/train.csv",
# "data/lists/PNEUMONIA/train.csv"]
# OFILE = "data/train.csv"
# FILE = ["data/lists/NORMAL/val.csv",
# "data/lists/PNEUMONIA/val.csv"]
# OFILE = "data/val.csv"
# FILE = ["data/lists/NORMAL/train.csv",
# "data/lists/Augmented/train.csv",
# "data/lists/PNEUMONIA/train.csv"]
# OFILE = "data/train_aug.csv"
# FILE = ["data/lists/NORMAL/val.csv",
# "data/lists/Augmented/val.csv",
# "data/lists/PNEUMONIA/val.csv"]
# OFILE = "data/val_aug.csv"
FILE = ["data/lists/NORMAL/test.csv",
"data/lists/PNEUMONIA/test.csv"]
OFILE = "data/test.csv"
SEED = 717
#___Main Method:
def main():
"""This is the Main Method.
This method contains training and testing session for image classification.
"""
# read contents from CSV files
content = []
for ifile in FILE:
content.extend([pd.read_csv(ifile)])
# combine contents in one list
df = content[0]
for frame in content[1:]:
df = df.append(frame)
# shuffle contents randomly and write in a CSV file
df = shuffle(df, random_state=SEED)
df.to_csv(OFILE, index=False)
return None
#___Driver Program:
if __name__ == "__main__":
main()
#
# end of file
"""ANI717"""