读excel表、csv

-(void)localAdressData{

    JianweiParam * Jianwei= [JianweiParam sharedInstance];


    NSString* filePath = [[NSBundle mainBundle] pathForResource:@"routes" ofType:@"csv"];

    NSString* fileContents = [NSString stringWithContentsOfFile:filePath];

    NSArray* DealersStrings = [fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

   

         NSMutableArray *  SearchDealerArray=[[NSMutableArray alloc]initWithCapacity:DealersStrings.count];

    //广东省,开平市,开平市三埠区美丽华家具商场,加州缘、,开平市三埠区曙光西路56,0750-2292338

    

    int countnumber=DealersStrings.count;

    

    NSLog(@"---COUNT--%d",countnumber);

    for(int idx = 0; idx <DealersStrings.count; idx++){

        NSLog(@"--id--%d",idx);

        

        NSString* currentPointString = [DealersStrings objectAtIndex:idx];

        NSArray* latLonArr = [currentPointString componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];

        

        DealerPerson *Person=[[DealerPerson alloc]init];

        

        Person.provinceStirng=[latLonArr objectAtIndex:0];

        Person.city=[latLonArr objectAtIndex:1];

        NSLog(@"--province--%@",[latLonArr objectAtIndex:0]);


        NSLog(@"--city--%@",[latLonArr objectAtIndex:1]);



        Person.shopString=[latLonArr objectAtIndex:2];

        Person.modelNumberString=[latLonArr objectAtIndex:3];

        Person.address=[latLonArr objectAtIndex:4];

        Person.phoneNumber=[latLonArr objectAtIndex:5];

        

        NSString * latitude =[latLonArr objectAtIndex:6];


        NSString * longitude =[latLonArr objectAtIndex:7];


        

        if ([latitude isEqualToString:@""]) {

            Person.latitudeString=23.12209;


            Person.longitudeString=113.417366;

        }else{

//            NSLog(@"latitudeString---%@",latitude);

//              NSLog(@"longitudeString---%@",longitude);

 

            Person.latitudeString=[latitude doubleValue];

            Person.longitudeString=[longitude doubleValue];

        }

      

        

      

        

        

        

        

        [SearchDealerArray addObject:Person];

        [Person release];

    }

    [Jianwei saveDealerPersonInfoToDB:[SearchDealerArray copy]];

    [SearchDealerArray release];

    

}

你可能感兴趣的:(读excel表、csv)