Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:47:32+00:00 2026-06-12T00:47:32+00:00

I have three arrays. The first array contains strings, same as the second, however

  • 0

I have three arrays. The first array contains strings, same as the second, however the third one contains NSNumber‘s. Anyways, back on topic… how can I create a csv (which is an excel/numbers) file like a spreadsheet to contain this data. Is it possible?

These are my three arrays:

locationArray – contains many strings
dateArray – contains many strings
milesArray – contains many NSNumber‘s

But each array contains the same amount of objects so (for example in a table view) you can piece the data together in an NSDictionary. It is like a chain.

So then it would look like this:

NSDictionary *firstFlight = [NSDictionary dictionaryWithObjectsAndKeys:[locationArray objectAtIndex: 0], @"FlightName", [dateArray objectAtIndex: 0], @"FlightDate", [milesArray objectAtIndex: 0], @"FlightMiles", nil];

And that dictionary would contain a flight (the functionality of this test app is to log flights). So if I enumerated this using a for loop and replaced objectAtIndex: with the looped number I could get many dictionaries of the flights.

Now that you understand how my data structure works. How can I create an excel/numbers/spreadsheet CSV file to look like this for example (just a screencapture from what it could look like):

(MILES DATA IS JUST MADE UP)

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:47:33+00:00Added an answer on June 12, 2026 at 12:47 am
    
    NSArray *firstArray, *secondArray, *thirdArray;
    
    NSMutableString *csv = [NSMutableString stringWithString:@"Name,Date,Miles"];
    
    NSUInteger count = [firstArray count];
    // provided all arrays are of the same length
    for (NSUInteger i=0; i<count; i++ ) {
        [csv appendFormat:@"\n\"%@\",%@,\"%d\"",
            [firstArray objectAtIndex:i],
            [secondArray objectAtIndex:i],
            [[thirdArray objectAtIndex:i] integerValue]
         ];
        // instead of integerValue may be used intValue or other, it depends how array was created
    }
    
    NSString *yourFileName = @"your filename";
    NSError *error;
    BOOL res = [csv writeToFile:yourFileName atomically:YES encoding:NSUTF8StringEncoding error:&error];
    
    if (!res) {
        NSLog(@"Error %@ while writing to file %@", [error localizedDescription], yourFileName );
    }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three arrays, all the same size: xout % cell array xin %
I have two arrays, each containing strings. The first array is a list of
I have the following three arrays and need to create a new two-dimensional array
I have two String arrays a,b. String a [] = {one,two,three}; String b []
I have 3 String arrays with constants. eg: String[] digit = {one, two, three};
I have a created 4 dimensional array in JavaScript. One column contains String values
I have an double level array. On the first level there are about 10
I have three arrays and I have copied all these arrays into a single
I have three arrays (it's written in C but that is not important, it
I want to do permutation in Perl. For example I have three arrays: [big,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.