ArrayMac > Function display > ENCofCSV

     ∇ r←ENCofCSV x;peel_quotes;enclose_quotes;outside_fillexp                                      
[1]   ⍝∇ 20111110/20150825 ra⌈ --()--                                                               
[2]    x←x~qTCLF                                                                                    
[3]    :If qTCNL∊x                                                                                  
[4]        r←ENCofCSV¨ENCofSS qTCNL,x                                                               
[5]    :ElseIf 0∊⍴x                                                                                 
[6]        r←x                                                                                      
[7]    :Else                                                                                        
[8]        peel_quotes←{0∊⍴⍵:⍵ ⋄ ('"'=⍬⍴⍵)↓(-'"'={⍵}/⍵)↓⍵}                                          
[9]        outside_fillexp←{                                                                        
[10]           ~1∊ll←'{{'⍷⍵:(⍴⍵)⍴1                                                                  
[11]           ~1∊rr←'}}'⍷⍵:(⍴⍵)⍴1                                                                  
[12]           ~+\ll-¯2⌽rr}                                                                         
[13]       enclose_quotes←{{0∊⍴⍵:⍵ ⋄ (⍬⍴⍵),1↓¨1↓⍵}(1,1↓(0=2|+\'"'=⍵)∧(⍵=',')∧(outside_fillexp ⍵))⊂⍵}
[14]       r←peel_quotes¨{','=⍬⍴⍵:{(⊂''),1↓⍵}enclose_quotes' ',⍵ ⋄ enclose_quotes ⍵}x               
[15]   :EndIf                                                                                       
     ∇                                                                                              

Page served at: Wed, 08 Apr 2020 04:37:44 AST.