从chcsv解析器中获取每个字段

时间:2012-12-20 17:55:12

标签: ios csv ios6

当我使用CHCSV解析器时:来自https://github.com/davedelong/CHCSVParser的代码:

NSArray *a = [[NSArray alloc] initWithContentsOfCSVString:lunchFile
                                                         encoding:NSUTF8StringEncoding
                                                            error:&err];

我得到以下数组

(
        (
        Date,
        Item,
        Desc
        "price#",
        "add#",
        rate,
        "",
        ""
    ),
        (
        "12/10/12",
        abc,
        "abc equipment",
        abc678,
        "Y.7.A",
        "555,007.21",
        "",
        ""
    ),

如何从每个字段获取值?。第一行是列名,它需要填充sqlite db.I我是一个菜鸟如何从每个字段中获取值。我正在使用fmdb提前输出sqlite.db.Thanks中的字段。

1 个答案:

答案 0 :(得分:0)

发现它:

NSArray *s1 =  [a objectAtIndex:4];


 NSLog(@"  element :  %@", [s1 componentsJoinedByString:@","]);    

    for (NSUInteger i = 0; i < s1.count; i++) {
        NSString* string = [s1 objectAtIndex:i];
         NSLog(@" This is : %d  %@",i , string);

    }