> I am unsure how to check for an empty string and skip it if it is empty.
"" empty?
> I have been unsuccessful in getting it to write to a single file in an append
> mode, or to create a sequence of files as it goest through 'each'
> 'with-directory-files'.
>
>
>
>
"/tmp/foo" ascii [ "hello world" print ] with-file-appender
> The people who have entered the data mixed mm/dd/yyyy with dd/mm/yyyy in the
> original Excel sheets that I created my CSV sheets from. Of course it is easy
> to check for numbers > 12, but dates like 10/10/2010 are problematic.
> I had to use file-lines vs. file>csv to bring in the data, or else I could
> not get my regexp working on the CSV from file>csv.
>
>
>
>
The csv vocab makes sequences of strings. The regexp vocab only works on
strings.
IN: scratchpad "a,b,c" string>csv .
{ { "a" "b" "c" } }
You might want to look into words like "find", "find-from", or other sequence
operations if you want regexp like searching or matching.
> Not really an issue, but are there any cominators or other commands that
> could consolidate all of the 'swap drop swap' commands I have resorted to
> using. Or 'first second' commands? I wish there was more Factor code out
> there on the web to learn from...
Well, "swap drop swap" is "nip swap". But often when you are using stack
shuffling words, you are not taking advantage of higher level words or
combinators. Try reading:
IN: scratchpad "combinators" help
Also, you might find this blog post I wrote on refactoring a word that has ugly
stack shuffling to be useful:
http://re-factor.blogspot.com/2010/05/evenly-partition-integer.html
>
>
> "resource:work/thodw/data" [
> [
> utf8 file-lines
> [ R/ Date|Ticket|\"Show Time:\"/ re-contains? ] filter
> dup
> 0 swap nth string>csv
> first second 10 cut swap "," append
> swap drop swap
> dup
> 1 swap nth string>csv
> first second 5 cut swap "," append
> swap drop swap
> 2 swap nth string>csv
> dup
> first second "," append swap
> first 4 swap nth
> 3append
> append
> print
> #! utf8 csv>file
> ] each
> ] with-directory-files
>
>
>
>
You might find something like this makes it cleaner:
utf8 file-lines
[ regexp ] filter
{ 0 1 2 } swap nths
[ string>csv ] map
Also, if you are appending and then printing, you can just write the strings as
they happen, or try looking into the "make" vocabulary:
[ "Hello" % CHAR: \s , "World" % ] "" make .
Best,
John.
------------------------------------------------------------------------------
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