• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Reading the multiple data from csv

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone. Firs end foremost a short purpose of application I am trying to create.

Main goal is to provide monitoring widget for my coaches. To be able to do that a certain data needs to be stored. I used for data storing the csv file. The 4 columns are Date, Time,No. of Happy,No of Normal,No of Sad.
Since I want to make a visual graphical interpretation of the results I need to call the data back from the csv.

With the help of different tutorials I was able to get the data out for third column (No of Happy) however, cant find the way how to call than the 4th and 5th column, and also the Date.

The reason behind is, that I would like to plot a chart based on the 3 columns with aChartEngine.

can you please assist me on this matter?

Saving the stats to csv



Reading the stats from csv for usage in chart



Thank you for your help
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at the CSV to see if it's properly formatted? Post it here.

What is the point of storing data as file (no matter the format) if the same app reads it later? Why not keep it in memory?
 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Have you looked at the CSV to see if it's properly formatted? Post it here.

What is the point of storing data as file (no matter the format) if the same app reads it later? Why not keep it in memory?



but if there is 5 practices per week for a 6 month period, wouldn't it be better to have it stored in file somewhere?

Unfortunately I cant save the actual file so hope copy of the text will do....


Aug-30-2014,08:06 AM,0,0,0
Sep-05-2014,08:09 AM,0,3,2
Sep-05-2014,08:10 AM,0,3,2

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but if there is 5 practices per week for a 6 month period, wouldn't it be better to have it stored in file somewhere?


We don't know what that data is intended for, that's why I asked. My question was not about long-term storage, it is about the fact that the app writes to a file and then reads form the same file - that seems inefficient to me. Why convert Java objects to a file representation only to convert that back to Java objects within the same app? (Especially if it gives you problems, I might add :-)

At a quick glance, the CSV looks OK. What are the values of the elements of the "a" array for the line that's giving you trouble?
 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

but if there is 5 practices per week for a 6 month period, wouldn't it be better to have it stored in file somewhere?


We don't know what that data is intended for, that's why I asked. My question was not about long-term storage, it is about the fact that the app writes to a file and then reads form the same file - that seems inefficient to me. Why convert Java objects to a file representation only to convert that back to Java objects within the same app? (Especially if it gives you problems, I might add :-)

At a quick glance, the CSV looks OK. What are the values of the elements of the "a" array for the line that's giving you trouble?



the problem is that I cant find the way how to call out the 4th column and the 5th to obtain variables with the splitting the string lines. and than use those values as reference numbers for a second data line in the chart.





 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "call out"? What exactly is the problem? The code shows how to access the 3rd element - what prevents you from similarly accessing the other elements?
 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:What do you mean by "call out"? What exactly is the problem? The code shows how to access the 3rd element - what prevents you from similarly accessing the other elements?



the problem is that no matter what I try, I cant access the 4th element and use it to draw an extra line to the chart.


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the problem is that no matter what I try, I cant access the 4th element and use it to draw an extra line to the chart.

normalList.add(Integer.parseInt(a[3]));


The code you posted seems to do just that, so what exactly happens when you you run? TellTheDetails
 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

the problem is that no matter what I try, I cant access the 4th element and use it to draw an extra line to the chart.

normalList.add(Integer.parseInt(a[3]));


The code you posted seems to do just that, so what exactly happens when you you run? TellTheDetails



There is no error, just application does not show the second line on a graph (Data for "mDataNormal") at all, so I was thinking that there is something wrong with obtaining the array.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case, an answer to this would be helpful:

Ulf Dittmer wrote:What are the values of the elements of the "a" array for the line that's giving you trouble?

 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:In that case, an answer to this would be helpful:

Ulf Dittmer wrote:What are the values of the elements of the "a" array for the line that's giving you trouble?



The values are integers, which need to be than used for data projection on graph. Is than array a problem or the Dataset?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You misunderstood. What are the *actual* values? Not what you think they are, but what they actually are. Print them out and make sure they match your assumptions.
 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You misunderstood. What are the *actual* values? Not what you think they are, but what they actually are. Print them out and make sure they match your assumptions.



Thanks for assisting me with the basic print idea . Since array values were exactly what it was stored in the csv,I took a look at the following part from bottom up and correct it:





 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So now everything works ?
 
Lovro Bajc
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:So now everything works ?



Yep work perfectly, thanks a lot. Just one more question still regarding the previous post you made:

Ulf Dittmer wrote:What is the point of storing data as file (no matter the format) if the same app reads it later? Why not keep it in memory?



Obviously there would be a lot of practices and variables stored after certain period of time. Would you still keep it in memory or would you go for something else? I am quite new on this side as you have probably noticed, so any suggestion is most helpful to open my horizons .

thank you again

brg
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For long-term storage (more than the runtime of the app) saving it as a file would is fine, preferably on shared public storage (http://developer.android.com/guide/topics/data/data-storage.html#filesExternal) where other apps or a file manager can easily get at it.

I was only advising in-memory storage because it seemed like you were transferring data form one part of the app to another part of the app, while the app was running. For that particular purpose a file would be an inappropriate choice.
 
knowledge is the difference between drudgery and strategic action -- tiny ad
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic