The below code is not working. its unable retrieve Record count and merge files
Class Util
{
ClassMethod zPyRecordCount(inputfile) As %Integer [ Language = python ]
{
import pandas as pd
import iris
import io
try:
df = pd.read_csv(inputfile, sep='|')
recordcount=len(df.index)
sys.stdout.write(len(df.index))
return recordcount
except Exception as e:
return 0
}
ClassMethod zPymergefiles(file1, file2, outputfilename) As %Boolean [ Language = python ]
{
import pandas as pd
import iris
import io
try:
dataframe1=pd.read_csv(file1, sep='|')
dataframe2=pd.read_csv(file2, sep='|')
jsondf1 = dataframe1.to_json(orient='records', indent=0)
jsondf2 = dataframe2.to_json(orient='records', indent=0)
mergedjsondf=pd.concat([jsondf1, jsondf2], ignore_index=True)
with open(outfilename, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=0, ensure_ascii=False)
return 1
except Exception as e:
return 0
}
}
Set mergeStatus=##class(Util).zPymergefiles(inputfile1,inputfile2, "outfile1.json")