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

  • SEARCH
  • Home
  • 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 8517495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:43:02+00:00 2026-06-11T05:43:02+00:00

Possible Duplicate: How to share all the data i have stored using sqlite database

  • 0

Possible Duplicate:
How to share all the data i have stored using sqlite database between two devices to reuse the data by dumping in another device

I want to import a sqlite Database and save it as a CSV file and then mail this file via email.

can i import sqlite in to csv format in iphone app programmatically to attach in mail composer


i used following functio to get the data base file

+(NSString*)getSqliteDBFile
{
      NSString *docsDirectoryPath;
      NSArray *dirPaths;
      NSString *databasePath;
      NSFileManager *fileManager = [NSFileManager defaultManager];

      // Get the documents directory
      dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

      docsDirectoryPath = [dirPaths objectAtIndex:0];
      NSLog(@"path :%@", docsDirectoryPath);

      // Build the path to the database file
      databasePath = [[NSString alloc] initWithString: [docsDirectoryPath stringByAppendingPathComponent: @"LeadGenDB.sqlite"]];
      NSLog(@"path :%@", databasePath);


      return databasePath;
}

Now I nees to convert sqlite file to csv file

  • 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-11T05:43:03+00:00Added an answer on June 11, 2026 at 5:43 am

    you can not convert direct sqlite to csv. First you get your all database data and write into csv file.use below example for create csv and send it.

    NSString *csvString =@"1,2 , 3 , 4, 5 ,6 , 7";
    
            for(int i=0;i<rangeData.count ;i++)
            {
                NSArray *temp = [di timeCalculation:[[rangeData objectAtIndex:i] objectForKey:@""] :[[rangeData objectAtIndex:i] objectForKey:@""]];
    
    
    
                NSString *strTemp =[NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@,%@",
    
                                    [NSString stringWithFormat:@"%@",[simpleDate stringFromDate:[[NSDate alloc]initWithTimeIntervalSince1970:[[[rangeData objectAtIndex:i] objectForKey:@""] floatValue]]]],
                                    [NSString stringWithFormat:@"%@",[shrotDate stringFromDate:[[NSDate alloc]initWithTimeIntervalSince1970:[[[rangeData objectAtIndex:i] objectForKey:@""] floatValue]]]],
                                    [NSString stringWithFormat:@"%@",[shrotDate stringFromDate:[[NSDate alloc]initWithTimeIntervalSince1970:[[[rangeData objectAtIndex:i] objectForKey:@""] floatValue]]]],
                                    [NSString stringWithFormat:@"%@",[shrotDate stringFromDate:[[NSDate alloc]initWithTimeIntervalSince1970:[[[rangeData objectAtIndex:i] objectForKey:@""] floatValue]]]],
                                    [NSString stringWithFormat:@"%@",[shrotDate stringFromDate:[[NSDate alloc]initWithTimeIntervalSince1970:[[[rangeData objectAtIndex:i] objectForKey:@""] floatValue]]]],
    
                                    [NSString stringWithFormat:@"%@",[[temp objectAtIndex:0] stringByReplacingOccurrencesOfString:@": " withString:@""]] ,
                                    [NSString stringWithFormat:@"%@",[[temp objectAtIndex:1] stringByReplacingOccurrencesOfString:@" : " withString:@""]]];
                csvString = [NSString stringWithFormat:@"%@ \n %@",csvString,strTemp];
            }
    
            //create instance of NSFileManager
            NSFileManager *fileManager = [NSFileManager defaultManager];
    
            //create an array and store result of our search for the documents directory in it
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    
            //create NSString object, that holds our exact path to the documents directory
            NSString *documentsDirectory = [paths objectAtIndex:0];
            NSLog(@"Document Dir: %@",documentsDirectory);
    
            NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.csv", @"userdata"]]; //add our file to the path
            [fileManager createFileAtPath:fullPath contents:[csvString dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
    
    
            NSData *csvData =[NSData dataWithContentsOfFile:fullPath];
            MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
            controller.mailComposeDelegate = self;
            [controller setToRecipients:[NSArray arrayWithObject:@""]];
            [controller setSubject:@"CSV Export"];
            [controller setMessageBody:@"" isHTML:NO]; 
            [controller addAttachmentData:csvData mimeType:@"text/csv" fileName:@"userdata.csv"];
            [self presentModalViewController:controller animated:YES];
            [controller release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Common elements comparison between 2 lists I have two Lists: [Apples, Bananas,
Possible Duplicate: Can you share a file and it's history between two git repositories?
Possible Duplicate: Call controller's function from another controller / Share data between controllers I
Possible Duplicate: How does Facebook Sharer select Images? Want to have share thumbnail when
Possible Duplicate: Datatemplate inheritance I have several data types that are not subclasses, nor
Possible Duplicate: VS2008 Setup Project: Shared (By All Users) Application Data Files? Please can
Possible Duplicate: Rewrite all queries to not need the .php extension using a mod_rewrite
Possible Duplicate: Are file descriptors shared when fork()ing? Suppose I have following code in
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How to avoid “!= null” statements in Java? Share your thoughts..

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.