Hello,
I’m getting a `length error here for some reason and can’t figure out why.
I’ve got sample text file attached which looks something similar to
0000 test ANN 1212 -99999999999 20140310 13:41:57 20140214 18:41:00 USD 0 -99999 -999990000 test QTR 1212 -99999999999 20140310 13:41:57 20140214 18:41:00 USD 0 -99999 -999990000 test ANN 1312 -99999999999 20140311 13:50:23 20140214 18:41:00 USD 20140417 -99999 -99999
and I’m trying to parse with fixed-lengths like
("SSSDFDTDTSDFF";6 6 3 4 12 8 8 8 8 3 8 6 6) 0:
:c:/test.txt but gives
length
also tried just pulling everything a string but same result
(" *************";6 6 3 4 12 8 8 8 8 3 8 6 6) 0:
:c:/test.txt`
I’ve made sure type string count is the same as fixed-length count and is the same as the tabs in the file.
Anyone have any ideas what I’m doing wrong here?
Thanks
Check
count each read0 `:c:/test.txt
I think you’ll find that the counts don’t match the sum of your widths
Terry
If you take your first string
s:“0000 test ANN 1212 -99999999999 20140310 13:41:57 20140214 18:41:00 USD 0 -99999 -99999”
and take your widths:
i:6 6 3 4 12 8 8 8 8 3 8 6 6
reshape your string according to your widths:
q)(0,sums i)_s
"0000 "
" test "
" "
"ANN "
"1212 -999999"
"99999 20"
"140310 1"
"3:41:57 "
"20140214"
" 18"
":41:00 U"
"SD "
" 0 "
"-99999 -99999"
You can see your lengths are off.
I think you widths need to be approx:
i:7 8 4 5 13 9 9 9 9 11 2 7 6
Those work -
q)(13#"*";i)0:enlist s
"0000 "
"test "
"ANN "
"1212 "
"-99999999999 "
"20140310 "
"13:41:57 "
"20140214 "
"18:41:00 "
"USD "
"0 "
"-99999 "
"-99999"
On Friday, June 9, 2017 at 6:16:30 PM UTC+1, Roni Hoffman wrote:
Hello,
I’m getting a `length error here for some reason and can’t figure out why.
I’ve got sample text file attached which looks something similar to
0000 test ANN 1212 -99999999999 20140310 13:41:57 20140214 18:41:00 USD 0 -99999 -999990000 test QTR 1212 -99999999999 20140310 13:41:57 20140214 18:41:00 USD 0 -99999 -999990000 test ANN 1312 -99999999999 20140311 13:50:23 20140214 18:41:00 USD 20140417 -99999 -99999
and I’m trying to parse with fixed-lengths like
("SSSDFDTDTSDFF";6 6 3 4 12 8 8 8 8 3 8 6 6) 0:
:c:/test.txt but gives
length
also tried just pulling everything a string but same result
(" *************";6 6 3 4 12 8 8 8 8 3 8 6 6) 0:
:c:/test.txt`
I’ve made sure type string count is the same as fixed-length count and is the same as the tabs in the file.
Anyone have any ideas what I’m doing wrong here?
Thanks
Got it, this helped. Thanks very much, you guys are masters.
Anyone know why this one is giving length error? I seem to be doing the same thing and my column length look ok to me
q)s:"0000 87482X10 TLMR TALMER BANCORP INC 1.000 P 0 S F NA 20140220 "q)i:(7 9 9 34 6 2 2 2 2 2 3 7 9 )q)(0,sums i)_s("0000 ";"87482X10 ";"TLMR ";"TALMER BANCORP INC ";"1.000 ";"P ";" ";"0 ";"S ";"F ";"NA ";" ";"20140220 ";" ")q)(14#"*";i)0:enlist s
length`
Thanks
sum[i] doesn’t equal count s
Ohh Got it, thanks very much