thought regarding import and export of data (was Many Cards vs. Lists vs. XML)
Sadhunathan Nadesan
sadhu at castandcrew.com
Tue Feb 19 10:10:15 EST 2008
Regarding Swami's comment of exporting to tab delimited (or delimited
in general) - see code snippet below -
Reason: in working with many customers and external agencies or
authorities over the years (a lot of years), this has proven to
be the lowest common denominator and something almost everyone can
work with. This includes banks, major film studios, executives at
all levels, accountants, pension funds, credit unions, 401k plan / fsa
plan administrators, software producers, competitors, film production
offices, state tax authorities such as CA EDD, various state SUI plans,
and the IRS. Most of them use Excel, which can import such data with
a few clicks. In a recent project, the IRS was using MS Access, which
imports in the same way, and, like Excel, expects the first row of data
to contain the field definitions.
The one thing I might add is that if the original data is coming from
a non Windows system application other than Rev (such as, in our case,
SQL on Linux), line endings may have to be converted, e.g.,
repeat for each line thisLine in inputData
replace CRLF with empty in thisLine
write thisLine & cr to file outputFile
end repeat
Now, obviously, XML is the future and these Windows products support it,
but in my experience with customers, they may lag behind the times in
these matters. Working with tech guys is of course, different! :-)
By the way, the data from our SQL database defaults to the pipe symbol
as the delimiter (easily handled by Excel), and the split command
is useful for processing this kind of data. So it would be nice to
see it fixed.
Cheers,
Sadhu
..............
Swami wrote:
# export, tab delimited:
# let's get a header first
# assume card 1 has all fields that any record might have
repeat with y = 1 to the number of flds of card 1
put the short name of fld y & tab after tOutput
end repeat
put cr after tOutput
# now the data:
put the card names of this stack into tRecords
repeat for each line x in tRecords
repeat with y = 1 to the number of flds of card x
put fld y & tab after the output
end repeat
put cr after tOutput
end repeat
put tOutput into url "file:/myExport.txt"
More information about the use-livecode
mailing list