group in the grouping vocabulary splits a sequence into subsequences, like
this:
( scratchpad ) { 3 6 2 5 8 7 } 2 group .
{ { 3 6 } { 2 5 } { 8 7 } }
It would be a good idea to first flatten the list and then run 2 group on
it.
Marshall
On Sat, Mar 10, 2012 at 7:44 AM, Robert Herman <rpjher...@gmail.com> wrote:
> I solved Windows-specific installation issues I had with Factor, and now I
> have moved on to playing with Factor. I thought I would best learn it by
> trying to accomplish a work-related task with it instead of just trying to
> rewrite some previous python code. Anyway, I have a CSV formatted file that
> has been exported from an Excel file. The original Excel sheet was laid out
> like a horizontal form, so there is no easy relationship between headers
> and rows. Please forgive me, and tell me if I should put the code or file
> snippet elsewhere, and I will do so in future posts.
>
> Here is a sample of the CSV output:
>
> "Show Report",,,,
>>
>> ,,,,
>>
>> "Show Name:","TTTTT1 ",,,
>>
>> "Show Date:","24/02/2012 (Fri)",,,
>>
>> "Show Time:",05:00:00 PM,,,
>>
>> "Venue:","DDDDDD WWWWW TTTTTTT",,,
>>
>> ,,,,
>>
>> "Door Open:",04:30:00 PM,,"Admission Time:","30 mins"
>>
>> ,,,,
>>
>> "Announcement:",05:00:00 PM,,,
>>
>> ,,,,
>>
>> "Show Start:",05:02:00 PM,,"Show End:",06:29:00 PM
>>
>> ,,,,
>>
>> "Door Close:",06:37:00 PM,,"Dismission Time","8 mins"
>>
>> ," ",,,
>>
>> "Duration:","87 mins",,,
>>
>> ,,,,
>>
>> "Ticket issued:",1029,,"Total Attendance",998
>>
>> ,,,,
>>
>> "Remarks:","1. blah blah blah blah blah blah blah blah blah.",,,
>>
>> ,,,,
>>
>> ,,,,
>>
>> ,,,,
>>
>> ,,,,
>>
>> "Incidents:",,,,
>>
>>
> I simply wanted the value right after Show Date: 24/02/2012, Ticket
> issued: 1029 and Total Attendance 998, like so: 24/02/2012,1029,998
> I don't need headers.
> Here is the code I have been using in the listener:
>
> USING: io.encodings.ascii io.encodings.utf8 regexp csv
>>
>>
>>> "resource:work\\ATT\\ATT1.csv" ascii file-lines
>>
>> [ R/ Date|Ticket/ re-contains? ] filter
>>
>> dup
>>
>> 0 swap nth
>>
>> #! "\r\n" append
>>
>> swap
>>
>> 1 swap nth
>>
>> 23 cut
>>
>> swap
>>
>> #! "\r\n" append
>>
>> swap
>>
>> 3append
>>
>> "resource:work\\ATT\\parsed.csv" utf8 set-file-contents
>>
>>
> This gets me 95% of the way there, but it is surely not the cleanest or
> Factor-like way to go. Here's the file contents results:
>
>> "Show Date:","24/02/2012 (Fri)",,,"Ticket issued:",1029,,"Total
>> Attendance",998
>
>
> Using a series of cuts could get me there, but is very inefficient. I
> tried other regexp like re-split on comma and re-replace with blanks, but
> these threw errors, or returned with no effect.
>
> Any tips on other functions or structures would be most appreciated. I
> tried slice, joins, the CSV library,and some others, but mainly received
> errors asking for a string, when the Inspector showed that I had a string
> on the top of the stack. How can I index the string like: string[0] or
> string[2:4]? Or some other way of achieving the end results?
>
> Thanks. I hope the post is not too long...
>
> Rob
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk