Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • A note: fileread() assigning binary string scalars

    An observation after failing to read a Stata scalar using Stata Python sfi Scalar getString(); The scalar defined by fileread() is marked as binary ( help dta##strls_gso ):
    Code:
    clear
    set obs 1
    python: from sfi import Scalar, StrLConnector
    
    tempname S
    tempvar s ss
    tempfile f
    
    scalar `S' = "A" * ( 2045 + 1 ) // strL
    gen `s'  =  `S'
    python:  len(Scalar.getString("`S'")) ; StrLConnector(0,0).isBinary()  
    
    * 2046
    * False
    
    di filewrite("`f'",`S')
    * 2046
    
    scalar `S' =  fileread("`f'") // marked as binary help dta##strls_gso
    generate `ss'  =  `S'
    python: len(Scalar.getString("`S'")) ; StrLConnector(1,0).isBinary()
    
    * 0
    * True
    Last edited by Bjarte Aagnes; 10 Mar 2020, 11:20.

  • #2
    You didn't get a quick answer. Part of the problem is that you didn't actually ask a question.

    As you probably know, getting the answer depends on someone active on the list actually using what you're doing. It is possible that a Python expert is not actually answering questions on the list.

    Comment


    • #3
      According to the list FAQ anything Stata-related is appropriate, not restricted to questions. My post is a remark on Stata string scalars and fileread() assigning binary string scalars. This is technical information, and will (should) be ignored by most readers. (BTW a Python expert would not help here if not also a Stata Corp developer) .

      Comment

      Working...
      X