mardi 7 mars 2017

waht is the best practive for If statement in python

Good after noon,

I am here for some help guys. Right now I am working in a csv file. Which look like this:

Datos,Unix,Tiempo
1376460059,,
4,,
33.23,1376460060.0,01:01:00.000000
33.29,1376460060.25,01:01:00.250000
33.29,1376460060.5,01:01:00.500000
33.29,1376460060.75,01:01:00.750000
33.29,1376460060.90,01:01:00.900000
33.33,1376460061.0,01:01:01.000000
33.29,1376460061.25,01:01:01.250000
33.33,1376460061.5,01:01:01.500000
33.29,1376460061.75,01:01:01.750000
33.29,1376460061.90,01:01:01.900000
33.33,1376460062.0,01:01:02.000000
33.33,1376460062.25,01:01:02.250000
33.37,1376460062.5,01:01:02.500000
33.33,1376460062.75,01:01:02.750000
33.33,1376460062.90,01:01:02.900000

I would like to make an if statement or while loop which would allow me to only show me this "4 rows" of the csv file:

33.33,1376460061.0,01:01:01.000000
33.29,1376460061.25,01:01:01.250000
33.33,1376460061.5,01:01:01.500000
33.29,1376460061.75,01:01:01.750000

I have gotten some help before but i think there is a better way to do it. Once I have there 4 rows I would like to do some math on the first row.

This is what i have:

 import numpy as np
 DATOS = np.genfromtxt(csvname+'NEW.csv', delimiter=',', dtype=None)[3:]


 for COLUMN in DATOS:
      if 1376460061.0 >= COLUMN[2] < 1376460061.75:
      print "D: "+COLUMN[0]+" TU: "+COLUMN[1] +" H: " + COLUMN[2]

I really need your help to get this done. Many thanks.

Aucun commentaire:

Enregistrer un commentaire