• 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: CamelBones
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CamelBones


  • Subject: Re: CamelBones
  • From: Pierre Vaudrey <email@hidden>
  • Date: Thu, 29 Apr 2004 20:19:36 +0200

Le jeudi, 29 avr 2004, ` 13:09 Europe/Paris, Sherm Pendley a icrit :

> But what the heck, this is a "Cocoa" list, not an "Objective-C" list.
> Maybe you'll start a trend. ;-)
I'm currently beginning to write a CamelBones application for the
capture and/or update of genealogical data from census records. Many
people are capturing these data with Excel and Perl DBI::CSV seems
adequate for importing CSV files to Cocoa TableView. Paul Johnson's
GEDCOM library seems also very useful to manipulate genealogical data.
I have written a simple test application modeled from the Data Access
example from CamelBones site.
The opening of the csv file is made in the sub new of MyDatasource
package :

sub new {
# Typical Perl constructor
# See 'perltoot' for details
my ($proto, $filename) = @_;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
$self->{'items'}=[];
my $items = $self->{'items'};
#NSLog($filename);
#my
$filename="/Users/pierreva/Documents/perlGedcom/LCMenu/test.csv";
open(TSTFILE,"<$filename");
while (<TSTFILE>){
chomp;
my @fields = split(";",$_);
# Make a new hash to hold the row
my $row = {'id' => $1,'sex' => $2,'name' => $3,'birthDate' =>
$4};
$row->{'name'} =$fields[0];
$row->{'birthDate'} =$fields[2];

# Push the new row on the list
push @$items, $row;
}
close(TSTFILE);

return $self;
}

After updating the values at the GUI level the saveAs is done
according the saveData sub of the same MyDatasource package:

sub saveData($$)
{
my ($self, $filename) = @_;
#NSLog($filename);
open(TSTFILE,">$filename");
foreach my $row (@{$self->{'items'}}){
my $name=$row->{'name'};
my $date=$row->{'birthDate'};
my $outstr = join(";", $name, $date);
print TSTFILE $outstr."\n";
}
close (TSTFILE);
}

I plan to replace the opening and saving with methods of the DBI::CSV
libraries.
Is this design the right way ?

Thanks for your advice

Pierre
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: CamelBones
      • From: Sherm Pendley <email@hidden>
    • Re: CamelBones
      • From: Bob Ippolito <email@hidden>
References: 
 >Re: CamelBones (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Connecting Mulitple Nibs
  • Next by Date: XTools 1.2 and ODBC problems?
  • Previous by thread: Re: CamelBones
  • Next by thread: Re: CamelBones
  • Index(es):
    • Date
    • Thread