Hi, Thorsten,
From: "Thorsten Moeller"
<snip>
> So, am going to do it with blocks and nested blocks.
>
> I made a large container block to put all the records in. Every record
> starts with an record id, followed by a nested block containing up to
several
> blocks with date-informations, followed by three other values.
>
> sample!!
>
> allorders:[
> "3465436" [[["1.6.2002" "20:00:00" "1,00" "98,10"]] "1,00" "98,10"
> "3004"]
> ]
>
> now i have another record with the same id like this, read from a file:
> 3465436;20.06.2002 15:00:00;1,00;98,10;3004
>
> if there is already a record in "all" i just want to add a new block like
> this
> ["20.06.2002" "15:00:00" "1,00" "98,10"]
> to the nested block in the existing record and add 1,00 to the existing
1,00
> and the 98,10 to the existing 98,10.
>
> the final record should look like this:
> "3465436" [[["1.6.2002" "20:00:00" "1,00" "98,10"]["20.06.2002" "15:00:00"
> "1,00" "98,10"]] "2,00" "196,20" "3004"]
>
> what happend is, for some reason i cannot find out, that the added block
> overrides the existing one and is inserted a second time and the values
are not
> added.
> so that the result is:
> "3465436" [[["20.06.2002" "15:00:00" "1,00" "98,10"]["20.06.2002"
"15:00:00"
> "1,00" "98,10"]] "1,00" "98,10" "3004"]
>
> Here is the code
<snip>
>
> Any ideas
I had to set up a sample file inorder to work out the details, so I
commented out two lines at the top that you will need and added a data
block. It appears to work. It should at least provide another alternative
approach. Watch for wrapped lines.
Hope it helps!
--Scott Jones
REBOL []
;orders: read/lines %AusgabeCSV.txt
;if exists? %allorders.txt [delete %allorders.txt]
orders: [
"3465436;01.06.2002 20:00:00;1,00;98,10;3004"
"3465436;20.06.2002 15:00:00;1,00;98,10;3004"
]
allorders: copy []
dates: copy []
date: copy []
foreach full orders [
line: parse full ";"
either a: select/skip allorders line/1 2 [
append/only a/1/1 copy/part next line 4
change a/1/2 to-string ((to-decimal a/1/2) + (to-decimal line/4))
change a/1/3 replace trim/with to-string ((to-money a/1/3) +
(to-money line/5)) "$" "." ","
][
append allorders copy line/1
append/only allorders copy reduce [
reduce [(copy/part next line 4)] copy line/4 copy line/5 copy
line/6]
]
]
print "Finished"
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.