5

How Hot Does it Get Inside a Car During a Heat Wave?

 3 years ago
source link: https://hackernoon.com/how-hot-does-it-get-inside-a-car-during-a-heat-wave-a13u37y4
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
How Hot Does it Get Inside a Car During a Heat Wave?
timestamp := records[i][3][:len(records[i][3])-4]
seconds, err := strconv.Atoi(string(timestamp[len(timestamp)-2:]))

if err != nil {
  log.Printf("Error: %v", err)
}

if seconds >= 30 {
  timestamp = timestamp[:len(timestamp)-2] + "30"
} else {
  timestamp = timestamp[:len(timestamp)-2] + "00"
}

ourValue, err := strconv.ParseFloat(records[i][1], 64)

I wrote a Go program live on stream that did the following:

0 reactions

First, I took the CSV with the fewest records in it. That way I knew we would have the most overlapping values. Some data streams were longer, but they wouldn’t have values in the smaller streams. So this was the starting point.

0 reactions

I read in that file and created a table with the timestamp and the value included. The timestamp would be our index.

0 reactions
func FirstInsert(db *sql.DB, timestamp string, value float64) (bool, error) {

	insertReadingSql := `INSERT INTO Reading (TimeStamp, CarTemperature) VALUES (?,?)`

	statement, err := db.Prepare(insertReadingSql)

	if err != nil {
		log.Println("Failed to prepare SQL Statement")
		return false, err
	}

	_, err = statement.Exec(timestamp, value)

	if err != nil {
		log.Println("Failed to insert data")
		log.Printf("Timestamp: %v \n Value: %v \n", timestamp, value)
		return false, err
	}

	return true, nil
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK