Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Good Evening!

I am doing a calculations template.
Calculation involves 2 values, FAT and Solid Non-FAT (SNF). Each FAT-SNF pair has an amount assigned to it. The values of FAT and SNF will be input from a Milk-Analyzer. Once the values of FAT and SNF are input into their respective textboxes, the amount corresponding to the FAT-SNF Pair needs to be displayed in another textbox and readied for calculation.

I have attached an
New Rate Chart Cow.zip
(629 Bytes) Downloaded 189 times
for understanding the the amount estimation of each FAT-SNF pair.

I am trying to figure out two things:

1. How to import
The file attached so that the data can be accessed for FAT-SNF pairs like:
FAT - SNF = Amount
2.1 - 7.0 = 24.3
2.6 - 7.8 = 26.5

What I cannot understand is that, for example: Value in column A3 (FAT) can be paired with B3 to T3. So what editables should be created for importing and storing the FAT-SNF pairs? I had thought of having cloned pages for each pair, but for csv import I go ____________ (blank :o )

2. Once the data is available in Couch back-end I could use AJAX to query the data and update the amount field. Then I get caught in the vicious-circle of how to import (i.e. back to #1 above). Also, every time a query is fired, using AJAX, it will take time to return the value, leading to a slow system. So can we have the entire data of FAT-SNF pairs and their Amount readily accessible, for faster processing. (faster processing s needed because in a span of 4 hours an approx of 20,000 ltr of milk needs to be collected from 67 collection centers, as on date, but to increase by month end to 165 collection centers)

Another concern that is at hand is that collection centers are in remote locations (villages), where internet connectivity will be available only through mobile network with working speeds between EDGE and 3G. Hence also, I was wondering if data can be made available. Every time a form is filled and submitted the page reloads, but the data of FAT-SNF and Amount should remain intact. Data can be fetched every time the user logs in and purged when a user logs out. If the data changes it is only after the collection shift ends.

One more thing to mention there are different CSV's for Cow and Buffalo FAT-SNF pairs, around 600+ entries for each cattalo.

All possible inputs are appreciated.

Regards,
Aashish
Image
where innovation meets technology
Data exchange without page reloads are very quick. No need to think about it, because your complete data amounts to a few kilobytes, which is nothing really. Ideally, you can preload all numbers into array(s) for instant manipulation. 8-)

Pairs can be stored alltogether in a single textarea in json or csv. Textarea data can be read into array by using <cms:each> or directly <cms:capture as='json'>. Compared to such quick access to data kept in one place, it will thus be a bad idea to keep values as cloned pages :)
@trendoman,
This makes sense, I suppose I was way too engrossed with the quantum of data to be transferred.

I can save the data into a textarea, pre-load it and use it for calculations.

But I still cannot understand one thing. How do I import the data as json or csv from the excel file (csv). Since an importer works line by line. Even if I do consider the SNF values as headers, how can I actually generate a FAT-SNF and Amount combination.

The client will always have an excel file (csv file) to import. This file keeps on changing frequently and at times different collection centers can have different SNF-FAT and Amount values implemented on the same day. This can be handled but how to import the file as client wont be creating a file to suite the needs of the system. The client receives a file from the authority and will use it as is.

You have given me a clear picture for the #2 doubt. I am still wondering about the #1 doubt. I could create a json array to be stored in textarea as (or as deems fit for use):
Code: Select all
{
   "cow": [{
      "fat": 1,
      "snf": 1,
      "amount": 10
   }, {
      "fat": 2,
      "snf": 2,
      "amount": 20
   }],
   "buff": [{
      "fat": 1,
      "snf": 1,
      "amount": 10
   }, {
      "fat": 2,
      "snf": 2,
      "amount": 20
   }]
}

but how do I generate this above markup upon file import is still not clear in my mind.

Regards,
Aashish
Image
where innovation meets technology
Json schema looks very far away from the csv table. :roll: It will not be easy, unless there is some kind of trick to make it work quicker.. I can not suggest anything valuable today :?

Edit: After some thought, I suggest to create a better json schema in a way that allows you to quickly access values. I mean, write ideal conditions for requesting some value. And the result can be very interesting - it is okay to duplicate values, create redundant rows, in order to have fast access to required value. Json does not need to be pretty, it can be ugly - combining for example associative array and indexed array, - but values will be easy to find.
I hope it gives some perspective.
4 posts Page 1 of 1