From eec9c2639ff76649f7c28dea0e70d05aeff1b25d Mon Sep 17 00:00:00 2001 From: seimit Date: Tue, 2 Nov 2021 21:46:06 +0200 Subject: [PATCH] Fixed issue #10 --- Metis/tools/STDFHelper.py | 11 +++++++---- Metis/tools/stdf2csv.py | 8 +------- Metis/tools/stdf2ph5.py | 17 ++++++----------- tests/test_stdf_convert.py | 12 ++++++++---- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Metis/tools/STDFHelper.py b/Metis/tools/STDFHelper.py index dcf3658f..39090736 100644 --- a/Metis/tools/STDFHelper.py +++ b/Metis/tools/STDFHelper.py @@ -242,10 +242,13 @@ def get_str_field(str_fields, stdf_record, rec_name): for field_name in fields: field_type = stdf_record.fields[field_name]['Type'] - if field_type.startswith('C'): - full_field_name = rec_name+'.'+field_name - if full_field_name not in str_fields: - str_fields.append(full_field_name) + if field_type.startswith('C') or \ + field_type.startswith('B*') or \ + field_type.startswith('x'): + + full_field_name = rec_name+'.'+field_name + if full_field_name not in str_fields: + str_fields.append(full_field_name) def get_stdf_record(ver, byteorder, rec_len, rec_typ, rec_sub, rec): diff --git a/Metis/tools/stdf2csv.py b/Metis/tools/stdf2csv.py index 9b0da460..e621a318 100644 --- a/Metis/tools/stdf2csv.py +++ b/Metis/tools/stdf2csv.py @@ -78,13 +78,7 @@ def stdf2csv(self, stdr_record, output_folder, part_num): #Converting the list as string if type(value) == list: v = str(value) - v = v.replace(',','') - v = v.replace('[','') - v = v.replace(']','') - value = v.replace('\'','') - value = '"' + value + '"' - s += value.replace(' ', '') - s += ',' + s += '"' + v + '",' continue else: value = str(value) diff --git a/Metis/tools/stdf2ph5.py b/Metis/tools/stdf2ph5.py index 34fb1609..24ff2df4 100644 --- a/Metis/tools/stdf2ph5.py +++ b/Metis/tools/stdf2ph5.py @@ -5,6 +5,7 @@ import os.path import pandas as pd from tqdm import tqdm +from ast import literal_eval import Semi_ATE.STDF.FAR as FAR import Semi_ATE.STDF.ATR as ATR @@ -31,7 +32,6 @@ import Semi_ATE.STDF.EPS as EPS import Semi_ATE.STDF.GDR as GDR import Semi_ATE.STDF.DTR as DTR - try: from .STDFHelper import STDFHelper from .HDF5Helper import HDF5Helper @@ -412,12 +412,13 @@ def stdf2pandas(self, stdf_file, output_file): dataset_path = SHP.STDF_RECORDS_DIR+'/'+file_name+'/' for record_name in frames.keys(): - + fn = record_name + ".csv" if os.path.isfile(fn): data = pd.read_csv(fn) data_loc = dataset_path+record_name - # Sets string type for STDF fields with C*n type after CSV import + # Sets string type for STDF fields with C*n/B*n/kxTYPE type + # after CSV import fields = data.keys() for field in fields: if field in str_fields: @@ -511,16 +512,9 @@ def stdf2csv(self, stdr_record, part_index, bps_seq_name, wir_start_t): column_name = record_name+"."+field_name value = stdr_record.fields[field_name]['Value'] # Converting the list as string - # like ['1', '1', '0', '0', '1', '1'] -> 110011 if type(value) == list: v = str(value) - v = v.replace(',','') - v = v.replace('[','') - v = v.replace(']','') - value = v.replace('\'','') - value = '"' + value + '"' - s += value.replace(' ', '') - s += ',' + s += '"' + v + '",' continue else: value = str(value) @@ -574,6 +568,7 @@ def main(): debug = False else: debug = True + stdf2hdf52pandas = SHP(debug) for input_file in args.input: diff --git a/tests/test_stdf_convert.py b/tests/test_stdf_convert.py index acd80bfc..4bfb823d 100644 --- a/tests/test_stdf_convert.py +++ b/tests/test_stdf_convert.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- - -from Metis.tools import SHP -from Metis.tools import SCC - import time import h5py import os import os.path +import sys +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + + import Semi_ATE.STDF.FAR as FAR import Semi_ATE.STDF.ATR as ATR import Semi_ATE.STDF.WIR as WIR @@ -15,6 +15,10 @@ import Semi_ATE.STDF.PCR as PCR import Semi_ATE.STDF.MRR as MRR +from Metis.tools.stdf2ph5 import SHP +from Metis.tools.stdf2csv import SCC + + # Tests are not finished yet. Only basic tests were written, not real ones. def test_SHP():