Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

Options
rv27783
rv27783 Posts: 3

This is my code in Extension tool test :smile: from com.parasoft.api import *
from time import gmtime, strftime
from soaptest.api import *
from java.util import *
from org.apache.poi.hssf.usermodel import *
from java.io import FileInputStream
import sys
reload(sys)

encoding: utf-8

def setName(input, context):
OldExcelDT_PAID = context.getValue("ExcelFile","dt_paidOld")
NewDBDT_PAID = context.getValue("Generated Data Source","DT_PAID")
# Replaceing old values with new dcn values into delete_dcn_list.txt
file = open("H:\temp\report.xls", 'r')
filedata=file.read()
filedata = filedata.replace(OldExcelDT_PAID,NewDBDT_PAID)
f= open("H:\temp\report.xls","w")
f.write(filedata)
f.close()
file.close()
return (filedata)

-- I am getting below error
--Error Message:
DataSource: ExcelFile (row 1): Error during script execution. View Details for more information.

Traceback (most recent call last):

File "", line 17, in setName

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

-- How I can fix this. Basically I am updating Excel cell values to something new.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,230 ✭✭✭
    edited May 2017
    Options

    It looks like you are trying to read and write an Excel file as if it were text and not binary (this won't work). Instead, if you are trying to use Apache POI library then I'd recommend looking over their how-to for proper usage: https://poi.apache.org/spreadsheet/how-to.html

    Using java libraries from Jython works but you may also want to consider using Groovy which has a more java-like API and syntax.