Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
include resources "rosetta_csv.csv"
|
||||
|
||||
/*
|
||||
|
||||
This ASCII text data is saved as a resource file
|
||||
named "rosetta_csv.csv" in the application bundle.
|
||||
|
||||
C1,C2,C3,C4,C5
|
||||
1,5,9,13,17
|
||||
2,6,10,14,18
|
||||
3,7,11,15,19
|
||||
4,8,12,16,20
|
||||
|
||||
*/
|
||||
|
||||
void local fn ManipulateCSV
|
||||
CFURLRef url = fn BundleURLForResource( fn BundleMain, @"rosetta_csv", @"csv", NULL )
|
||||
CFStringRef csvString = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
|
||||
CFArrayRef csvArray = fn StringComponentsSeparatedByCharactersInSet( csvString, fn CharacterSetNewlineSet )
|
||||
CFMutableStringRef mutStr = fn MutableStringWithCapacity(0)
|
||||
long i
|
||||
|
||||
MutableStringAppendFormat( mutStr, @",%@,SUM,AVG\n", csvArray[0] )
|
||||
for i = 1 to len(csvArray) - 1
|
||||
CFArrayRef nums = fn StringComponentsSeparatedByString( csvArray[i], @"," )
|
||||
CFNumberRef sum = fn ObjectValueForKeyPath( nums, @"@sum.self" )
|
||||
CFNumberRef avg = fn ObjectValueForKeyPath( nums, @"@avg.self" )
|
||||
MutableStringAppendFormat( mutStr, @"R%ld,%@,%@,%@\n",i,csvArray[i],sum,avg )
|
||||
next
|
||||
|
||||
NSLog( @"%@", mutStr )
|
||||
|
||||
CFURLRef desktopURL = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )
|
||||
url = fn URLByAppendingPathComponent( desktopURL, @"final_csv.csv" )
|
||||
fn StringWriteToURL( mutStr, url, YES, NSUTF8StringEncoding, NULL )
|
||||
end fn
|
||||
|
||||
fn ManipulateCSV
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue