read fixed record file

Hi, I’m trying read a file which has fixed length record. I tried the example from code.kx.com, it’s giving me length error.

http://code.kx.com/wiki/JB:KdbplusForMortals/loading\_tables\_from\_stored\_data#1.1.3\_Table\_from\_Fixed\_Record\_Text\_File

Please help.

Thanks

looks like an erroneous example.

q)flip idsym`px!(“ISF”;4 11 6) 0:enlist “1001DBT12345678 98.61\n1002EQT98765432 24.57\n1003CCR00000011 21.23”

id   sym         px   


1001 DBT12345678 98.61

1002 EQT98765432 24.57

1003 CCR00000011 21.23

$ more closepx.txt 

1001DBT12345678 98.611002EQT98765432 24.571003CCR00000011 21.23

Maybe you have a trailing char (line feed) in your text file?

q)hcount`:closepx.txt

63

q)flip idsympx!("ISF";4 11 6) 0: :./closepx.txt

id   sym         px   


1001 DBT12345678 98.61

1002 EQT98765432 24.57

1003 CCR00000011 21.23

q)\hexdump closepx.txt

“0000000 31 30 30 31 44 42 54 31 32 33 34 35 36 37 38 20”

“0000010 39 38 2e 36 31 31 30 30 32 45 51 54 39 38 37 36”

“0000020 35 34 33 32 20 32 34 2e 35 37 31 30 30 33 43 43”

"0000030 52 30 30 30 30 30 30 31 31 20 32 31 2e 32 33   "

“000003f”

if you’re having trouble dropping the final line feed in your text file

you can specify start and length as

q)flip idsympx!("ISF";4 11 6) 0: (:./closepx.txt;0;-1+hcount `:./closepx.txt)

id   sym         px   


1001 DBT12345678 98.61

1002 EQT98765432 24.57

1003 CCR00000011 21.23

thanks very much for the help. It worked.