+ (NSMutableArray *)transferByArray:(NSMutableArray *)specList {
NSInteger space = specList.count/401;
NSMutableArray *newList = [NSMutableArray array];
// 写csv
NSString *path = [YXG_FileTools pathByFileName:@"yxg401.csv" path:[YXG_FileTools pathByDirectoryName:@"yangxuguang003"]];
NSOutputStream *output = [[NSOutputStream alloc] initToFileAtPath:path append:YES];
[output open];
if (![output hasSpaceAvailable]) {
NSLog(@"❌没有空间");
}
NSInteger result = 0;
for (NSInteger i = 0; i < 401; i ++) {
float value = [specList[i*space] floatValue];
[newList addObject:@(value)];
// 写入csv
NSString *string = [NSString stringWithFormat:@"%ld,%@\n",380+i,specList[i*space]];
uint8_t buffer[2048];
memcpy(buffer, [string UTF8String], [string length]+1);
result = [output write:buffer maxLength: [string length]];
}
[output close];
return newList;
}
网友评论