On 1/15/08 10:47 PM, "Peter Alcibiades" <[EMAIL PROTECTED]>
wrote:
> Its a childishly simple problem. There is a file with 15k records. Tab
> delimited. Each record has five fields and is of the form:
>
> number eg 123
> description eg Pen, Pencil
> price eg 2.00
> category eg AA, AB...
> date eg 12/4/2008, 21/5/2008 (UK style)
>
> We then have 30 fields, which are the combination of a category and a month.
> So for instance we need to look at each record, if and only if it has both AA
> in item 4 and /4/ in item 5, then add the price item 3 to field AAApril. If
> and only if it has both AA and /5/ then add it to AAMay, and so on. 6
> months, five categories = 30 fields..
Hi, Peter. Here's a technique that should work pretty fast. Does it work
for you?
on foo
put "AA,AB,AC,AD,AE" into tCategories
put "January,February,March,April,May,June" into tMonths
repeat for each item tCategory in tCategories
repeat for each item tMonth in tMonths
put 0 into field (tCategory & tMonth)
end repeat
end repeat
set itemdelimiter to tab
put URL "file:foo.txt" into tRecords
repeat for each line tRecord in tRecords
put item 5 of tRecord into tDate -- d/m/y
replace "/" with space in tDate
add item 3 of tRecord to tArray[item 4 of tRecord,word 2 of tDate]
end repeat
set itemdelimiter to comma
repeat for each key tKey in tArray
put item 1 of tKey into tCategory
put item 2 of tKey into tMonthNumber
put item tMonthNumber of tMonths into tMonth
put tArray[tKey] into field (tCategory & tMonth)
end repeat
end foo
Typical disclaimer: It's not tested, but at least it compiles.
-- Dick
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution