How to divide column values of a spreadsheet into ranges in an better way?
Its a kind of vague question. I have a spreadsheet, with few hundred columns. Each column represents values of one variable which is continuous. I want to create a second spreadsheet with same number of columns but the values of all the continuo开发者_Python百科us variables should be mapped to some ranges. Ranges of each variable are different.
e.g.
Col 1 Col 2 Col 3
0.41 123 12:45
0.53 345 05:23
0.57 354 09:23
0.89 687 09:34
should become:
Col 1 Col 2 Col 3
0.40 125 12:00
0.50 350 05:00
0.50 350 09:00
0.80 675 09:00
I know that I can do it with normal if-else loops while checking column number. All I am thinking is if an additional column is added somewhere is in-between, it will force me to do lot of changes. Is there any design pattern which is generally used for this? any help is greatly appreciated.
You're right, this is a vague question. Why don't you give these columns some meaningful names ("height", "length", "weight", whatever), and maintain a set of constants in your code that specifies which name corresponds to which numbered column. That way, if the column layout changes, you just need to change a single constant.
精彩评论