Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9786

Google Script Function that Outputs Time Interval given a starting cell value [closed]

$
0
0

I'll preface this by saying I don't know anything about script editing. My programming experience starts and ends with Matlab (I'd say I'm fairly good with it), so any resources you all might have to help a newbie learn the ropes I'd appreciate them! Anyways, the question!

enter image description here

I'll start with the goal: a chart that shows the number of times a truck appears in a 24 hour period.To do this, my train of thought was as follows:

  1. Start at the first time entry, this will have a fixed cell location (here it's A2). Store this value into an array (Can you do this?)
  2. Go to the next cell in Column A, so A3, and subtract the value in A2 from the value in A3.
  • If the difference in values is less than 24, store value A3 into the same array from before and go to the next cell and repeat step 2 with this new value (i.e. A4-A2)
  • If the difference in values is equal to 24, store value A3 into the same array from before and end loop
  • If the difference in values is greater than 24, store the value of the cell one before the last cell evaluated into the array from before (e.g. in the picture, the 24 hour period ends at A25. The script would find that A26-A2 = 24:30:00, which is greater than 24. So the value to store would be the value in the cell just before A26, i.e. cell A25. )
  1. At this point I would like to take the cells stored in the array created in step 2 and get the truck numbers corresponding to them. This would essentially be replacing the A's in the array with B's, but I don't know how you'd do it either.

  2. By now I'd have two arrays: Array1 with the times and Array2 with the trucks, both of the same length. This is where I'd want to use the arrays to make a bar graph with the y-axis corresponding to Array1 and the x-axis corresponding to Array2.

So there's the scope of the problem and my thought process. This is how I'd do it in Matlab if someone gave me data, but I don't know how you'd do it via script. I'm really looking for examples on how to do this kind of thing, as well as resources to learn script editing.Thanks!


Viewing all articles
Browse latest Browse all 9786

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>