Я новичок в программировании и в стеке, и решил начать с изучения цели c.
В глубине, я знаю.
Я застрял, пытаясь найти лучший способ для анализа файла EDL.
В основном это текстовый файл ASCII размером не более 100 КБ.
Вот структура типичного cmx3600 edl:
TITLE: EP1 FINAL.EDL SECTION2
FCM: NON-DROP FRAME
001 A199_C00 V C 20:38:24:15 20:38:26:04 10:30:00:02 10:30:01:16
* SOURCE FILE: A199_C008_0915AH_001
002 A199_C00 V C 20:34:48:17 20:34:51:23 10:30:01:16 10:30:04:22
* SOURCE FILE: A199_C007_0915VE_001
Я пытаюсь найти наилучший способ разбора или сканирования каждого элемента в поля / массивы, т. Е.
editNum = 001
tapeName = A199_C00
channel = V
Operation = C
sourceIn = 20:38:24:15
sourceOut = 20:38:26:04
recIn = 10:30:00:02
recOut = 10:30:01:16
sourceFile = A199_C008_0915AH_001
Это мой код:
-(IBAction)importEdl:(id)sender {
//defines an Array of allowed file types with file extension ".EDL and .edl"
NSOpenPanel *myPanel = [NSOpenPanel openPanel];
NSArray *fileTypes = [NSArray arrayWithObjects:@"EDL", @"edl", nil];
myPanel.allowedFileTypes = fileTypes;
myPanel.allowsMultipleSelection = NO;
if ([myPanel runModal] == NSOKButton)
{
NSString *theFilePath = [myPanel filename];
NSString *psEdlFile = [NSString stringWithContentsOfFile:theFilePath encoding:NSASCIIStringEncoding error:NULL];
// Reads the file as one string. EDL's are simple ASCII text files of roughly 50KB.
NSArray *psEdlLines = [psEdlFile componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
// Separates the data into lines.
if([psEdlLines count] == 0)
{
NSLog(@"Error!");
} //prints error if EDL file has no events.
NSUInteger count;
int i;
for (i = 0, count = [psEdlLines count]; i < count; i = i + 1)
{
NSString *lineStrings = [psEdlLines objectAtIndex:i];
NSLog(@"Line %d is %@",i+1,lineStrings);
//NSArray *linesEnum = [psEdlLines objectAtIndex:i];
//this creates an array of lines
//NSLog(@"index is: %d %@",i, linesEnum);
}
}
}
@end
Вывод:
2012-03-20 15:22:08.956 TestProgram[412:903] Line 1 is TITLE: EP1 FINAL.EDL SECTION2
2012-03-20 15:22:08.957 TestProgram[412:903] Line 2 is FCM: NON-DROP FRAME
2012-03-20 15:22:08.957 TestProgram[412:903] Line 3 is 001 A199_C00 V C 20:38:24:15 20:38:26:04 10:30:00:02 10:30:01:16
2012-03-20 15:22:08.957 TestProgram[412:903] Line 4 is * SOURCE FILE: A199_C008_0915AH_001
2012-03-20 15:22:08.957 TestProgram[412:903] Line 5 is 002 A199_C00 V C 20:34:48:17 20:34:51:23 10:30:01:16 10:30:04:22
2012-03-20 15:22:08.957 TestProgram[412:903] Line 6 is * SOURCE FILE: A199_C007_0915VE_001
2012-03-20 15:22:08.957 TestProgram[412:903] Line 7 is 003 A199_C00 V C 20:42:32:01 20:42:35:19 10:30:04:22 10:30:08:15
2012-03-20 15:22:08.957 TestProgram[412:903] Line 8 is * SOURCE FILE: A199_C009_0915RX_001
2012-03-20 15:22:08.957 TestProgram[412:903] Line 9 is
2012-03-20 15:22:08.958 TestProgram[412:903] Line 10 is
Я не очень далеко, как вы можете видеть.
Любые идеи будут высоко оценены.
Заранее спасибо,
Пит.