|
Import |
|
2004-04-21 |
http://www.barefeetware.com/appleworks/import/ |
|
Description |
Opens a CSV (comma separated values) file or a tab delimited text file into a new database or spreadsheet document. |
|
Enhancement Pack |
This is one of over 40 features in the Enhancement Pack for AppleWorks. |
|
Detail
The Import... item appears in the Document sub-menu of AppleWorks Scripts menu.Requirements
Select Import..., then choose the text file to be opened. It will determine whether the file uses tabs or commas, returns or linefeeds. If you are using AppleWorks 6, the database option will also allow you to specify the line from which to grab the field names.
Does not require any document to already be open.Advanced
On some versions of the Mac OS, reading the source file is more reliable (and faster) when used on a file stored locally, rather than on an AppleShare volume. So copy any source file locally before using Import.
This works with AppleWorks 6, and version 5.
Only registered users are permitted to use the supplied files after 14 days or edit them.
Import takes care of any quotes around field values.Scripting
In case you are curious, here are some snippets from the (run-only) script.Please email us any queries about this page.
Parsing each line into a list of field values:
set inQuotes to false
repeat with charN from 1 to lineLength
set thisChar to character charN in thisLine
if thisChar is linefeed or thisChar is return then
--skip
else if thisChar is "\"" then
set inQuotes to not inQuotes
else if thisChar is "," and not inQuotes or charN is lineLength then
set end in fieldList to thisField
set thisField to ""
else
set thisField to thisField & thisChar
end if
end repeat
Opening or inserting the converted data file into a spreadsheet or database:
if docType is "SS" then
open file tabPath as document type spreadsheet document -- using translator "ASCII Text"
else if awV5 then
open file tabPath as document type database document -- using translator "ASCII Text"
else
make new document at front with properties {document kind:database document} with data fieldNames
delete record 1 in database of front document
insert file tabPath -- using translator "ASCII Text"
activate
select menu item "List" in menu "Layout" -- kills AppleWorks
end if