, :
2010 07 16 17 00 0,5 0,5 5,0 0,3 4,0 SSE SSE 163 2010 07 16 16 00 0,6 0,5 5,9 0,3 3,8 SSE SSE 165 2010 07 16 15 00 0,5 0,5 6,7 0,3 3,6 SSE SW 151 2010 07 16 14 00 0,6 0,5 5,6 0,3 3,8 SSE SSE 153
, . , , 2010 :
f = open('data.txt')
for line in f:
for portion in line.split(' 2010')
If your data spans several years, then the Python module itertoolscan be very convenient. I often use a recipe grouper.
import csv
from itertools import izip_longest
csv_writer = csv.writer(open('eggs.csv', 'wb'), delimiter=',')
def grouper(n, iterable, fillvalue=None):
"""
>>> grouper(3, 'ABCDEFG', 'x')
['ABC', 'DEF', 'Gxx']
"""
args = [iter(iterable)] * n
return izip_longest(fillvalue=fillvalue, *args)
f = open('spam.txt')
for line in grouper(22, f.split('\t')):
csv_writer.writerow(line[2], line[12])