Navigation

    • Register
    • Login
    • Search
    1. Home
    2. A-I
    A

    A-I

    @A-I

    0
    Reputation
    2
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    A-I Follow

    Best posts made by A-I

    This user does not have any upvoted posts yet.

    Latest posts made by A-I

    RE: Reading unicode from file Python

    Thanks, I guess..

    For anyone else coming across this issue, to decode in python you need to ensure that you're using the correct encoding when reading the CSV file. Even if the CSV file is already encoded to what you are expecting. To make it work for us we did the below:

    with open(CSV, encoding='utf-8') as csv_file:

    Rather than

    with open(CSV) as csv_file:

    posted in General Talk •
    Reading unicode from file Python

    Hey,

    Having an issue trying to read unicode characters from a CSV file.

    I am not very experienced with python so apologies in advance.

    Context:
    We use a CSV as a list of names, places, organisations etc read them in c4d and render them as images with the files named as per the column we select from the CSV.

    Some names of people or their tribe names are in different languages, for us locally it is Māori, which as a lot of ā,ō,ū characters.

    Our python code below. I have tried adding in "data.decode('utf8')" but this didn't help, or rather it is likely I am doing it wrong.

    import c4d
    #Welcome to the world of Python
    import csv

    def main():
    global Output
    global TotRow
    global TotCol

    data = []
    
    with open(CSV) as csv_file:
        reader = csv.reader(csv_file)
        for row in reader:
            data.append(row)
    
    
    row = max(0, min(RowSel, len(data)-1))
    col = max(0, min(ColSel, len(data[0])-1))
    
    Output = data[row][col]
    TotRow = len(data)
    TotCol = len(data[0])
    

    Any advise would be greatly appreciated

    posted in General Talk •