• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How best to archive in CSV format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How best to archive in CSV format


  • Subject: Re: How best to archive in CSV format
  • From: Denis Stanton <email@hidden>
  • Date: Tue, 17 May 2005 14:08:34 +1200


On May 17, 2005, at 1:43 PM, Bob Ippolito wrote:


On May 16, 2005, at 9:37 PM, Brian Smith wrote:


On May 17, 2005, at 4:51 AM, Denis Stanton wrote:


I'm looking for advice on the best way to handle archiving my documents in csv (comma separated variable) format.

These doubts make me think I'm going about this all wrong. Should I be using the encode and decode system to convert to and from csvs format?


Look at the references document to NSString and NSArray since they have some methods for working with delimited data. You will find a couple of methods for working with making and parsing strings from arrays of strings and setting the delimiter to whatever you want, (NSString)componentsSeparatedByString: and (NSArray)componentsJoinedByString:. Also, you will find read and write methods for creating files.

That sounds like a really bad idea because you need to deal with quoting and such. You'll have to code this up by hand unless you can find existing C or Objective-C code to do it. NSStringScanner might help.


One alternative is to look at PyObjC, because Python ships with a csv module.. though it's not optimal since current versions have a limitation such that it only knows how to deal with bytestrings, not unicode, so you have to encode everything into utf-8 before putting it into the csv and decode it from utf-8 after getting it out.

In other words, it's time to decide whether you REALLY need CSV :)

-bob

Thanks Brian and Bob

I have a reasonable idea of how to do the string handling parts with componentsSeparatedByString and componentsJoinedByString.

That's not the part that worries me. My question whether I should be writing this CSV conversion stuff inside the standard methods encodeWithCoder and initWithCoder, and if so how. It seems the Cocoa architecture has a well-thoughtout mechanism for archiving and I should try and work within it. My problem is the example I have produces a binary coded disk file and I need csv text. I want to make the Cocoa archive mechanism work with csv.

I know that there are traps in this as one of my data columns could contain commas, so I need to worry about quotes, but for the present task I do have to conform to csv because I am going to propose this Cocoa application as a replacement for an existing web-browser based data entry program and it's important to show that it can simply replace the older program with out requiring anybody else to change.

Denis


Denis Stanton Orcon Internet Limited (09) 480 9299 http://www.orcon.net.nz




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: How best to archive in CSV format
      • From: "Louis C. Sacha" <email@hidden>
    • Re: How best to archive in CSV format
      • From: j o a r <email@hidden>
References: 
 >How best to archive in CSV format (From: Denis Stanton <email@hidden>)
 >Re: How best to archive in CSV format (From: Brian Smith <email@hidden>)
 >Re: How best to archive in CSV format (From: Bob Ippolito <email@hidden>)

  • Prev by Date: Re: From Panther to Tiger
  • Next by Date: Re: How best to archive in CSV format
  • Previous by thread: Re: How best to archive in CSV format
  • Next by thread: Re: How best to archive in CSV format
  • Index(es):
    • Date
    • Thread