-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeStamp.py
105 lines (72 loc) · 2.6 KB
/
timeStamp.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import time
import pandas as pd
import datetime, time
import pandas
import os, sys
import netCDF4
from stat import S_ISREG, ST_CTIME, ST_MODE
import numpy
import netCDF4
import csv
import dateutil.parser
'''
with open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20160809_whole_radial_wind_data.csv', 'rb') as f:
reader = csv.reader(f, delimiter='\t')
times = [datetime.datetime.strptime(timestamp, "%H:%M:%S") for _, timestamp in reader]
for i in range(len(times) - 1):
delta = times[i + 1] - times[i]
print ((delta.days * 24 * 60 * 60 + delta.seconds) * 1000 + delta.microseconds / 1000)
print(delta.total_seconds() * 1000)
v1 = [] #TimeStamp looks like 10/2/2016 12:00:00 AM
#f = open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20161002_reconstruction_wind_data.csv', 'r').readlines()
#'/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20160809_whole_radial_wind_data.csv'
'''
'''
with open("myfile.csv") as infile:
for line in infile:
appendtoNetcdf(line)
'''
'''
working single time GOOD!!!!!
f = open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20161002_reconstruction_wind_data.csv', 'r').readlines()
v1=[]
for line in f[1:]:
fields = line.split(',')
v1 = fields[0] #TimeStamp
print v1
csv_in = open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20161002_reconstruction_wind_data.csv', 'rb')
reader = csv.reader(csv_in)
v2 = [v1[1]]
print v2
date = datetime.datetime.strptime(v1, '%Y-%m-%d %H:%M:%S')
#for row in v1:
# date = datetime.datetime.strptime(row[0], '%H:%M:%S')
d = dateutil.parser.parse('1 Jan 2012 12pm UTC') # its that robust!
'''
#times working for full file
f = open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20161002_reconstruction_wind_data.csv', 'r').readlines()
v1 = [0] * 359295
i=1
for line in f[1:]:
fields = line.split(',')
v1[i] = fields[0] #TimeStamp
date = datetime.datetime.strptime(v1[i], '%Y-%m-%d %H:%M:%S')
#print v1[i]
i+=1
print v1[200]
#print v1[1]
#csv_in = open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20161002_reconstruction_wind_data.csv', 'rb')
#reader = csv.reader(csv_in)
#for row in v1:
# date = datetime.datetime.strptime(row[0], '%H:%M:%S')
#d = dateutil.parser.parse('1 Jan 2012 12pm UTC') # its that robust!
'''
This works to store everything in data
import csv
from datetime import datetime
def date_key(row):
return datetime.strptime(row[1].strip(), '%H:%M:%S')
with open('/Users/arnoldas/Desktop/Fall 2016/ASRC/sourcefolder/20160809_whole_radial_wind_data.csv', 'rb') as f:
data = list(csv.reader(f))
print data
'''