Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting values from spreadsheet

 
Padmaksha Mukhopadhyay
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone

My program wants to pull data from 4th coloum in a spreadsheet and count number of occurences in a variable

But the answers are comming wrong and not getting updated

Here is my code .

The 4th coloum has arround 50 values like , p0,p1, p2,p3


And the output comes like

Value of P0: 0
Value of P1: 0
Value of P2: 0
Value of P3: 2

Which is absolutely wrong
What am i doing wrong

Kindly help
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you're doing wrong is that you are using == to compare strings. Use .equals() instead, for example:
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait a minute. Is this Java or JavaScript? Keywords such as "function" and "var" make me think this is JavaScript, which is something completely different than Java.

If it is indeed JavaScript, then my previous answer about using .equals() is not the right answer.
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, it is JavaScript.

What's the expected data from sheet.getDataRange().getValues()?

You are looping the data from position 1 (for var i = 1...) is that correct? Also which kind of Object is data? Is it an Array, an Object, a custom Object? You have to provide us with more information to be able to help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic