Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weird escaped characters in jupyter notebook's output #61

Closed
Asuralf opened this issue Apr 13, 2022 · 2 comments
Closed

weird escaped characters in jupyter notebook's output #61

Asuralf opened this issue Apr 13, 2022 · 2 comments

Comments

@Asuralf
Copy link

Asuralf commented Apr 13, 2022

I used pyreadstat module to read a simple SAS file. the code goes like this in jupyter notebook

import pyreadstat as pyrs
from objprint import op

sas_path = './test_sas/foo.sas7bdat'
df, meta = pyrs.read_sas7bdat(sas_path, metadataonly=True)
# just wanted to check out what meta contains 
op(meta)

the brief output of current cell seems normal

Output exceeds the [size limit]. Open the full output data[ in a text editor]
<metadata_container 0x1bcf4bfa3e0
  .column_labels = [
    'projectid',
    'project',
...
    'project': '$'
  },
  .variable_value_labels = {}
>
<pyreadstat._readstat_parser.metadata_container at 0x1bcf4bfa3e0>

but after I clicked "in a text editor", the first lines look like this:

�[36m<metadata_container 0x1bcf4bfa3e0�[39m
  �[32m.column_labels�[39m = [
    'projectid',
    'project',

the weird characters actually look like small suqares contains 3 small letters ESC in the text editor.

@gaogaotiantian
Copy link
Owner

Those are the ANSI escape characters to colorize the output. If you directly open that in the editor it could output this weird stuff. The simple way to solve this is to simply add color=False as an argument in op(). You could also set it globally by op.config(color=False)

@Asuralf
Copy link
Author

Asuralf commented Apr 13, 2022

thanks, it works

@Asuralf Asuralf closed this as completed Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants