我收到的数据如下所示:
0,JW111101,Run Name
0,111116,Date
0,+2.5,Increment
0,2=0,Start Station
0,1=Fri 11 Nov 2016 14:21:44,Date & Time Stamp
0,6=1 Off 4On,Cycle Times
0,6=Fluke 189B,Meter Type
0,6=Racal Landstar,GPS Reciever
0,1=Fri 11 Nov 2016 14:21:47,Date & Time Stamp
0,6=COMPANY NAME,142156.00,29.0638153,95.3436157,-1.2
0,6=LINE NAME,142156.00,29.0638153,95.3436157,-1.2
1,6=Test Station,142255.00,29.0638145,95.3436133,-0.9
1,6=-1559 On NG,142255.00,29.0638145,95.3436133,-0.9
1,6=-1169 Off NG,142255.00,29.0638145,95.3436133,-0.9
1,6=1Approx.,142255.00,29.0638145,95.3436133,-0.9
1,6=AC 0.735,142255.00,29.0638145,95.3436133,-0.9
1,1558,GPS Not Available
1,1460,142350.00,29.0638166,95.3436115,-0.9
1,1185z,142351.00,29.0638167,95.3436116,-0.9
1,1554,142352.00,29.0638166,95.3436116,-0.9
我想找到第3列中最小和最大的数字。第三列实际上是一个utc时间戳 我最终的目标是能够弄清楚它们何时开始,何时结束以及它们的持续时间 有人能指出我正确的方向吗?
答案 0 :(得分:0)
假设您的数据位于名为random.csv
的文件中,您可以在此处阅读数据。
import csv
list_of_stuff = []
with open('random.csv') as readcsv:
row_object = csv.reader(readcsv)
for value in row_object:
list_of_stuff.append(value)
print list_of_stuff
现在您有一个列表列表,其中每个子列表都是您文件的一行。以下是有关在csv文件中阅读的文档:https://docs.python.org/2/library/csv.html
您的第三列包含无法转换为时间戳的字符串和整数,因此我无法为您提供帮助。不过,让我们假设第三列是全部整数。然后除了上面的代码之外你还可以使用它:
third_column = [row[2] for row in list_of_stuff]
print "max: ", max(third_column)
print "min: ", min(third_column)
print "range: ", max(third_column) - min(third_column)