Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / June 2006



Tip: Looking for answers? Try searching our database.

file creator id, etc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joseph Alotta - 08 Jun 2006 16:20 GMT
Greetings,

I am trying to read a CSV data file of names and addresses into Now  
Contact.  However the import feature does not see this file as it is  
ghosted.  My conclusion is that it is looking at the file creator  
information.

How do I see this information?  Apple-i, Get Info, does not show  
this.  How can I inspect these file attributes and how can I modify  
them with perl?

Joe.
Dominic Dunlop - 08 Jun 2006 17:05 GMT
> I am trying to read a CSV data file of names and addresses into Now  
> Contact.  However the import feature does not see this file as it  
[quoted text clipped - 4 lines]
> this.  How can I inspect these file attributes and how can I modify  
> them with perl?

Firstly, I'd try giving the files a ".txt" extension. That might  
persuade Now Contact of their acceptability.

If that doesn't work, you need the to use the MacPerl module:

$ perl -MMacPerl -lwe 'print join " ", MacPerl::GetFileInfo("Desktop/
random.tif")'
GKON TIFF

The corresponding interface to set the signature is  
MacPerl::FSpSetFInfo -- see the man page for details. (Although  
MacPerl is part of the Tiger essentials package, you have to load the  
optional BSD package to get the man page. But, as a Perl developer,  
you'll have done that.)

Finally, if this is a one-off job, you can do things by hand with the  
GetFileInfo and SetFile utilities from Apple's developer tools. They  
live in /Developer/Tools. Again, see the man pages for details.
Signature

Dominic Dunlop

Joseph Alotta - 08 Jun 2006 17:46 GMT
Thanks Dominic and John.   After playing around with it a little, the  
type attribute must be "TEXT".  I guess I can just do a call to system
() to set this.  Thank you for your help.

Joe.

[PowerBook-G4:~/Desktop] jja% /Developer/Tools/GetFileInfo c.txt
file: "/Users/jja/Desktop/c.txt"
type: ""
creator: ""
attributes: avbstclinmedz
created: 06/01/2006 17:58:50
modified: 06/08/2006 11:42:04
[PowerBook-G4:~/Desktop] jja% /Developer/Tools/SetFile -t "TEXT" c.txt
[PowerBook-G4:~/Desktop] jja%

>> I am trying to read a CSV data file of names and addresses into  
>> Now Contact.  However the import feature does not see this file as  
[quoted text clipped - 23 lines]
> the GetFileInfo and SetFile utilities from Apple's developer tools.  
> They live in /Developer/Tools. Again, see the man pages for details.
Dominic Dunlop - 08 Jun 2006 18:35 GMT
> Thanks Dominic and John.   After playing around with it a little,  
> the type attribute must be "TEXT".  I guess I can just do a call to  
> system() to set this.  Thank you for your help.

Careful! If you use SetFile to do this, you'll end up with a script  
that works only on systems that have devtools installed. Fine for  
your own use, but not for distribution.
Signature

Dominic Dunlop

John Delacour - 08 Jun 2006 22:00 GMT
>>Thanks Dominic and John.   After playing around with it a little,
>>the type attribute must be "TEXT".  I guess I can just do a call to
>>system() to set this.  Thank you for your help.
>
>Careful! If you use SetFile to do this, you'll end up with a script
>that works only on systems that have devtools installed...

The file type can also be set like this:

my $f =  "$ENV{HOME}/desktop/trash.csv";
open F, ">$f" or die $!;
print F "a,b,c,d,e";
`osascript -e '
tell app "finder" to set file type of posix file "$f" to "TEXT"
'`;

JD
John Delacour - 08 Jun 2006 17:36 GMT
>Greetings,
>
[quoted text clipped - 6 lines]
>this.  How can I inspect these file attributes and how can I modify
>them with perl?

Without loading Mac::Carbon you can get (and set) type and creator
with osascript in the shell, but it might be quicker (if milliseconds
are important) just to print the data to an anonymous file and have
NC read that, if it can.

#!/usr/bin/perl
my $csv = "$ENV{HOME}/factory/accounts/2006 accounts/bos_060216.csv";
my $temp_csv = "/tmp/temp.csv";
open CSV, $csv or die $!;
open TEMP, ">$temp_csv" or die $!;
print TEMP <CSV>;
my $type_creator = `
osascript -e '
tell app "Finder" to get {file type, creator type} of (posix file "$csv")
'`;
print "type, creator : $type_creator\n__________\n\n";
close TEMP;
open TEMP, "$temp_csv";
print <TEMP>;

JD
Chris Nandor - 14 Jun 2006 08:04 GMT
> Without loading Mac::Carbon you can get (and set) type and creator
> with osascript in the shell, but it might be quicker (if milliseconds
> are important) just to print the data to an anonymous file and have
> NC read that, if it can.

Not sure why anyone would do that, since Mac::Carbon comes with the Mac, and
the call to GetPerlInfo() is much simpler to use, and executes much faster.

$ time perl -MMacPerl=:all -e 'print join "|", GetFileInfo(shift)' file
R*ch|TEXT
real    0m0.197s
user    0m0.091s
sys     0m0.030s

$ time perl -e '$file = shift; print `osascript -e '\''tell app "Finder" to
get {file type, creator type} of (posix file "$file")'\''`' file
TEXT, R*ch
real    0m0.523s
user    0m0.196s
sys     0m0.112s

Perhaps you didn't think it would be so fast because you thought one had to
load ALL of Mac::Carbon?  The MacPerl module itself is very small.  But,
even the bigger modules load really fast on Mac OS X these days.  
Loading/importing the entire distribution -- Speech, Sound, InternetConfig,
OSA, AppleEvents, Notification, Process, Resources, and so on -- on my
PowerBook G4/1GHz:

$ time perl -MMac::Carbon -e1
real    0m0.938s
user    0m0.570s
sys     0m0.093s

Of course, Mac::Carbon does not work on Intel systems ... not for another
couple of weeks anyway.

Signature

Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Technology Group       pudge@ostg.com     http://ostg.com/

Joel Rees - 08 Jun 2006 22:33 GMT
> I am trying to read a CSV data file of names and addresses into Now
> Contact.  However the import feature does not see this file as it is
> ghosted.  My conclusion is that it is looking at the file creator
> information.
>
> How do I see this information?  Apple-i, Get Info, does not show this.

Not a  perl topic, but isn't there a Finder setting that determines
whether Get Info allows access to this or not?
Chris Devers - 08 Jun 2006 22:55 GMT
> Not a perl topic, but isn't there a Finder setting that determines
> whether Get Info allows access to this or not?

Not a Perl solution (or is Ruby close enough to count?), but
RCDefaultApp may help with problems like this:

http://www.rubicode.com/Software/RCDefaultApp/


Signature

Chris Devers

Joseph Alotta - 09 Jun 2006 18:22 GMT
Hi everyone,

I found that Now Contact needs to see the type = "TEXT" and that  
records need to be separated with a \r rather than a \n, and import  
works fine.

Unfortunately, there is no ability to specify paper size in Now  
Contact, so I can't use the lousy program for 11 X 17 paper.  I am  
going to use TextEdit to print instead.  Oh, well.

Joe.

>> I am trying to read a CSV data file of names and addresses into  
>> Now Contact.  However the import feature does not see this file as  
[quoted text clipped - 6 lines]
> Not a  perl topic, but isn't there a Finder setting that determines  
> whether Get Info allows access to this or not?

There might be but I don't know where it is.  If anyone knows, please  
tell us.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.