Re: tab delimited data file
Re: tab delimited data file
- Subject: Re: tab delimited data file
- From: Doug McNutt <email@hidden>
- Date: Thu, 26 Jun 2003 09:27:26 -0600
#!/usr/bin/perl
#
%used = (); # define a blank hash
open INPUT, $ARGV[0] or die "Can't open source file.\n";
# $/ = "\r"; # Uncomment this line for Mac line endings in the data file
while (<INPUT>)
{
@fields = split /\t/;
if (exists $used{$fields[1]} )
{
$used{$fields[1]} += 1; # count just for the fun of it
}
else
{
$used{$fields[1]} = 1; # a new find
print $_; # so print the line as read.
}
}
__END__
Sample command lines:
perl -w tabs.pl clipmac.tsv
perl -w tabs.pl clipmac.tsv > $output # to create a file by name
tabs.pl clipmac.tsv # if the execute bit is set for the source file.
I'll leave it to others to encapsulate it into an AppleScript with "quoted form".
The perl source needs to have Unix line ends. BBEdit is the way I do it.
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.