Skip to content
Snippets Groups Projects
Commit 46db8bd7 authored by Victor Zimmermann's avatar Victor Zimmermann
Browse files

Renaming, commenting, final.txts have now individual names. Collected in final directory.

parent fa33af60
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Merges .absinth-files into one document.
Collect file names from the directory specified in config.py. Ignore every first
line and merge the rest. Write to file with timestamp as name.
"""
import config
import os
import time
def main():
file_path = config.output
files = [file_path+'/'+f for f in os.listdir(file_path)]
results = list()
for f in files:
with open(f, 'r') as lines:
for line in lines.readlines()[1:]:
results.append(line.split('\t'))
results = sorted(results, key=lambda x: x[0])
time_int = int(time.strftime("%Y%m%d%H%M%S")[2:])
final_path = 'final/{}.absinth'.format(hex(time_int)[2:])
if not os.path.exists('final'):
os.makedirs('final')
final = open(final_path, 'w')
final.write('subTopicID\tresultID\n')
for r in results:
final.write('\t'.join(r))
final.close()
if __name__ == "__main__":
main()
import os
file_path = '/home/students/zimmermann/Courses/ws17/fsem/absinth/clustering/'
files = [file_path+'/'+f for f in os.listdir(file_path)]
results = list()
for f in files:
with open(f, 'r') as lines:
for line in lines.readlines()[1:]:
results.append(line.split('\t'))
sorted(results, key=lambda x: x[0])
final = open('final.txt', 'w')
final.write('subTopicID\tresultID\n')
for r in results:
final.write('\t'.join(r))
final.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment