-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combining pattern files (number of results) to one file.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Creates one file of all results files | ||
""" | ||
from os import walk | ||
from dt.utils.files import remove_file_if_exists | ||
|
||
results_path = "C:\\Users\\Imara\\Documents\\Server_results" | ||
f = [] | ||
state = "" | ||
for (dir_path, dir_names, filenames) in walk(results_path): | ||
for file in filenames: | ||
file_full_path = str(dir_path) + "\\" + str(file) | ||
f.append(file_full_path) | ||
|
||
remove_file_if_exists('pattern_data_total.csv') | ||
|
||
with open('pattern_data_total.csv', 'w', encoding="utf-8") as outfile: | ||
for entry in f: | ||
if "pattern_data" not in entry: | ||
continue | ||
if "final" in entry: | ||
state = "\u25B2final" | ||
elif "initial" in entry: | ||
state = "\u25B2initial" | ||
with open(entry, encoding="utf-8") as infile: | ||
file_input = infile.read().rstrip("\n") + state | ||
outfile.write(str(file_input)) | ||
outfile.write("\n") |