我需要从这个网站( https://www.bowdoin.edu/apps/mobile/nutrition.php - 基本上是一大块文本)中提取一堆数据,并最终将其保存到核心数据实体的属性中。
这是来自网站的一段文本可能看起来像(修剪)
Monday, May 06, 2013|Thorne|Breakfast
Item|Portion|SFA(g)|FATRN(g)|PUFA(g)|MONO(g)|CHOL(mg)|Na(mg)|CHO(g)|TDFB(g)|Sugar(g)|Pro(g)|VTAIU(IU)|VITC(mg)|Ca(mg)|Fe(mg)|KCal|Fat(g)
Oatmeal|2/3 Cup|0.18|0|0.37|0.32|0|261|10.81|1.7|0|2.6|0|0|10.91|0.7|62|1
Pancakes|2 each|0.289|0|0.486|0.486|6|350|33.08|1.5|5.54|2.99|29.98|2.75|72.12|1.03|160|1.47
Monday, May 06, 2013|Thorne|Lunch
Item|Portion|SFA(g)|FATRN(g)|PUFA(g)|MONO(g)|CHOL(mg)|Na(mg)|CHO(g)|TDFB(g)|Sugar(g)|Pro(g)|VT AIU(IU)|VITC(mg)|Ca(mg)|Fe(mg)|KCal|Fat(g)
Deli Bar Lunch|portion|4.384|0.003|1.157|2.731|47|735|33.12|2.9|3.5|15.06|807.02|4.91|148.58|3.07|297|11.46
Chilled Fruit S|6 oz portion|0.837|0|0.089|0.359|5|24|15.48|0.6|10.75|1.86|635.11|46.86|109.75|0.53|79|1.42
Monday, May 07, 2013|Thorne|Lunch
Item|Portion|SFA(g)|FATRN(g)|PUFA(g)|MONO(g)|CHOL(mg)|Na(mg)|CHO(g)|TDFB(g)|Sugar(g)|Pro(g)|VT AIU(IU)|VITC(mg)|Ca(mg)|Fe(mg)|KCal|Fat(g)
Italian Bread|slice|0.245|0.005|0.985|0.486|0|172|10.73|0.7|0.48|1.61|0|0|2.81|0.6|67|1.84
Orange Gelatin |1/2 Cup|0|0|0|0|0|53|17.59|0|0|1.52|0|0|2.74|0.04|74|0
研究已将我指向NSURLConnection
and NSString's stringWithContentsOfFile:encoding:error: method
,但我不确定如何使用它们。
我想主要问题是解析,因为我会在之后弄清楚这些coredata
东西。有什么建议么?