-
9 Aug 2011 11:52 AM #1
Unanswered: how to display csv data
Unanswered: how to display csv data
hi there!
what is the best way to read and display some data from a csv data source. lets say I want to display an apple financial report with touch charts...
thnx!
-
16 Aug 2011 9:27 AM #2
Hi - Unfortunately there is no buil-in CSV reader in Sencha Touch. I would try to convert the CSV string into JSON and then feed that into a Store. Given a CSV string with `\n` and `,` separators the code for converting it into JSON would eb something like this:
This code should return the json needed to create a store with it.Code:var json = [], lines = csv.split('\n'); for (var i = 0, l = lines.length; i < l; ++i) { var fields = lines[i].split(','), jsonElement = {}; jsonElement['field1'] = fields[0]; jsonElement['field2'] = fields[1]; //... etc for each field json.push(jsonElement); }
I hope his helps,
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote