Rocket U2 | UniVerse & UniData

 View Only
  • 1.  U2PY and universe Encoding Decoding with Python

    Posted 20 days ago

    Hello all, 

    I made a python script to read multivalue data in universe account and write in a file as CSV for example. 

    So, for decoding I use cp850. 

    Until that everithing working.

    When it's time to write I receive this error:

    error cp1252:

    UnicodeEncodeError: 'charmap' codec can't encode character '\u2591' in position 88: character maps to «undefined»

    So decode is good with cp850, ok with that ? 

    Problem is encoding ? 

    Maybe I can force encoding in utf-8 but I don't know how to do that ?

    Do you have an universe idea ? :-) 

    Thank you ! 

    Jean



    ------------------------------
    deleuze jean
    Rocket Forum Shared Account
    ------------------------------


  • 2.  RE: U2PY and universe Encoding Decoding with Python

    Posted 19 days ago

    Deleuze,

    Load the Pandas library into python.  

    Then look at some of these website examples:

    https://www.programiz.com/python-programming/pandas/methods/to_csv

    https://codefather.tech/blog/write-csv-pandas/

    Enjoy.



    ------------------------------
    Dave Evans
    Programmer
    Combined Transport Inc
    central point OR US
    ------------------------------



  • 3.  RE: U2PY and universe Encoding Decoding with Python

    PARTNER
    Posted 18 days ago

    use NOTEPATH++,  the fourth option in the menubar is encoding. Choose your flavor.

    In the bottom of that app, you will see the encoding used. Succes.



    ------------------------------
    Dino SEELIG
    CTO
    Tcco
    Drunen NL
    ------------------------------



  • 4.  RE: U2PY and universe Encoding Decoding with Python

    PARTNER
    Posted 18 days ago

    I am not sure cp850 is what you are looking for, but it suggests you are running on windows.   If this is u2py code running on the server, do a search in rocket's support knowledge base there is an environment variable you should look for:  PYTHONLEGACYWINDOWSSTDIO=iso8859-1 this maybe what you want.   I am not sure if you are using NLS in universe but one other thing that is problematic is this --> '\u2591' which would not be part of any latin character set, this would be a 3 byte sequence when encoded in UTF-8 as an example.  



    ------------------------------
    Aaron Titus
    Senior Architect
    F W Davison and Company Inc. DBA PrismHR
    Plymouth MA US
    ------------------------------



  • 5.  RE: U2PY and universe Encoding Decoding with Python

    ROCKETEER
    Posted 14 days ago

    Deleuze,

    I always find it easier to marshal the dynamic array into a Python list.  Then manipulating it becomes a lot easier.

    i.e. simple example, minus actually writing it to a file, but you should get the idea

    python> import u2py
    python> file = u2py.File("STATES")
    python> csv_string = ','.join(file.read("CA").to_list())
    python> print(csv_string)
    California,West,Pacific

    And like any thing in Python, there are many ways to do most things.



    ------------------------------
    Mike Rajkowski
    MultiValue Product Evangelist
    Rocket Internal - All Brands
    US
    ------------------------------