Last active
August 29, 2015 14:17
-
-
Save tinoji/a7c3402294aae73ce6c8 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import glob | |
import time | |
start = time.time() | |
file_name = [] | |
first = [] | |
other = [] | |
# ファイル名取得 | |
print("\nTable of data files in this directory.") | |
file_name.extend(glob.glob('*.txt')) | |
for name in file_name: | |
print('-' + name) | |
# 読み込み | |
for name in file_name: | |
with open(name, 'rb') as f: | |
if file_name.index(name) == 0: | |
first = f.readlines() | |
else: | |
other.append(f.read()) | |
f.close | |
# 始めのファイル以外は角度を削除 | |
other2 = [] | |
for i in other: | |
other2.append(i.split()) | |
for i in other2: | |
del i[0::2] | |
# 書き込み | |
g = open('OUTPUT.txt', 'w') | |
for i in range (len(first)): | |
g.write(first[i].rstrip("\r\n") + " ") | |
for j in range (len(other2)): | |
g.write(other2[j][i] + " ") | |
g.write("\n") | |
processing_time = time.time() - start | |
print("\nFinished in {0} sec.".format(processing_time)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment