Bom dia!
Eu tenho um ficheiro Csv com o seguinte formato!
[quote]
,SRFF File: D:\SPI Master program list\240-36-01_eng\240-36-01-B-01-E.SRF
,Panel Name: Panel Description,Lot Code: N/A,Device: N/A
,Units: Microns
,Date,Time,PanelId,Board,Location,Feature,HeightResult,Height,HeightUpFail,HeightLowFail,HeightTarget,AreaResult,Area,AreaUpFail,AreaLowFail,AreaTarget,VolumeResult,Volume,VolumeUpFail,VolumeLowFail,VolumeTarget,Valid,RegResult,XOffset,YOffset,RegShort%,RegLong%,RegShort%Fail,RegLong%Fail,BridgeResult,BridgeLength,BridgeFail
,07/08/2008,17:20:28,#1,Module 1,C181,Pad1 ,W,87.302147,212.5,75.0,125.0,P,211899.703125,383880,127960,255920,W,18802780.000000,57582032,15995009,31990018,P,P,-97.170998,11.670000,21.023582,2.107640, 40, 40,P,0.000000,700.000000
,07/08/2008,17:20:28,#1,Module 1,C181,Pad2 ,W,87.071892,212.5,75.0,125.0,P,203649.000000,383880,127960,255920,W,17642690.000000,57582032,15995009,31990018,P,P,-100.944099,-9.680000,21.839918,1.748239, 40, 40,P,0.000000,700.000000
,07/08/2008,17:20:28,#1,Module 1,C176,Pad1 ,P,89.921509,212.5,75.0,125.0,P,212768.906250,383880,127960,255920,W,18684450.000000,57582032,15995009,31990018,P,P,-99.287102,34.439999,21.481415,6.219975, 40, 40,P,0.000000,700.000000
,07/08/2008,17:20:28,#1,Module 1,C176,Pad2 ,F,106.477997,212.5,75.0,125.0,P,188879.406250,383880,127960,255920,P,19587040.000000,57582032,15995009,31990018,P,P,-89.126198,11.310000,19.283037,2.042622, 40, 40,P,0.000000,700.000000[/quote]
e eu tenho uma classe que primeiro estabelece uma ligaçao servidor remotamente
depois acede ao folder que contem os ficheiros csv através de um scaning recursivo!
ao aceder ao ficheiro vai contar os erros neste caso apresentado por um “F”.
Agora eu tenho uma parte de script que encontrei que me iria ajudar a retirar os valores adjacentes… e.g. F, 106.477997, 212.5,75.0, 125.0 - 07/08/2008,17:20:28,#1,Module 1,C176,Pad2
HeightResult, Height, HeightUpFail, HeightLowFail, HeightTarget - Date, time, Board, Location, feature!
este é o script:
[code]
public class InspectionResults{ public static final byte HEIGHT_AVG_RESULT = 7, HEIGHT_RANGE_RESULT = 12, AREA_AVG_RESULT = 15, AREA_RANGE_RESULT = 20, VOLUME_AVG_RESULT = 23, VOLUME_RANGE_RESULT = 28, HAV_FAILED_FEATURE_RESULT = 35, REG_FAILED_FEATURE_RESULT = 38, BRIDGE_FAILED_FEATURE_RESULT = 41; private String retrievedData[]; private boolean failed[]; /** * Constructs this InspectionResult with the data stored in the args. * This class expects 44 values within the range of the args. / public InspectionResults(String… args){ retrievedData = args; boolean temp[] ={ ((retrievedData[7].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[12].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[15].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[20].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[23].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[28].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[35].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[38].equalsIgnoreCase(“F”)) ? true: false), ((retrievedData[41].equalsIgnoreCase(“F”)) ? true: false) }; failed = temp; } /* * Returns true if the given value has failed, returns false otherwise. * It’s preferred to use the constants defined within this class to get the * desired information, and not regular ints. / public boolean hasFailed(byte result) throws Exception{ switch(result){ case HEIGHT_AVG_RESULT: return failed[0]; case HEIGHT_RANGE_RESULT: return failed[1]; case AREA_AVG_RESULT: return failed[2]; case AREA_RANGE_RESULT: return failed[3]; case VOLUME_AVG_RESULT: return failed[4]; case VOLUME_RANGE_RESULT: return failed[5]; case HAV_FAILED_FEATURE_RESULT: return failed[6]; case REG_FAILED_FEATURE_RESULT: return failed[7]; case BRIDGE_FAILED_FEATURE_RESULT: return failed[8]; default : throw new Exception(“Attempt to access invalid result type! Use the Result Constants to avoid this error!”); } } /* * Returns the value next to the specified result. / public String getAdjacentValue(byte result) throws Exception{ if(result >= 0 && result < retrievedData.length - 1) return retrievedData[result + 1]; else throw new Exception(“Error! Attempt to access column with either no adjacent value or outside of data-range!”); } /* * Simply returns a String representing the date for each value in this class. */ @Override public String toString(){ String temp = “”; for(String element : retrievedData){ if(element.toString() != retrievedData[retrievedData.length - 1]) temp += element + ", "; else temp += element; } return temp; }}public class InspectionResults{
public static final byte HEIGHT_AVG_RESULT = 7,
HEIGHT_RANGE_RESULT = 12,
AREA_AVG_RESULT = 15,
AREA_RANGE_RESULT = 20,
VOLUME_AVG_RESULT = 23,
VOLUME_RANGE_RESULT = 28,
HAV_FAILED_FEATURE_RESULT = 35,
REG_FAILED_FEATURE_RESULT = 38,
BRIDGE_FAILED_FEATURE_RESULT = 41;
private String retrievedData[];
private boolean failed[];
/**
* Constructs this InspectionResult with the data stored in the args.
* This class expects 44 values within the range of the args.
*/
public InspectionResults(String... args){
retrievedData = args;
boolean temp[] ={
((retrievedData[7].equalsIgnoreCase("F")) ? true: false),
((retrievedData[12].equalsIgnoreCase("F")) ? true: false),
((retrievedData[15].equalsIgnoreCase("F")) ? true: false),
((retrievedData[20].equalsIgnoreCase("F")) ? true: false),
((retrievedData[23].equalsIgnoreCase("F")) ? true: false),
((retrievedData[28].equalsIgnoreCase("F")) ? true: false),
((retrievedData[35].equalsIgnoreCase("F")) ? true: false),
((retrievedData[38].equalsIgnoreCase("F")) ? true: false),
((retrievedData[41].equalsIgnoreCase("F")) ? true: false)
};
failed = temp;
}
/**
* Returns true if the given value has failed, returns false otherwise.
* It's preferred to use the constants defined within this class to get the
* desired information, and not regular ints.
*/
public boolean hasFailed(byte result) throws Exception{
switch(result){
case HEIGHT_AVG_RESULT:
return failed[0];
case HEIGHT_RANGE_RESULT:
return failed[1];
case AREA_AVG_RESULT:
return failed[2];
case AREA_RANGE_RESULT:
return failed[3];
case VOLUME_AVG_RESULT:
return failed[4];
case VOLUME_RANGE_RESULT:
return failed[5];
case HAV_FAILED_FEATURE_RESULT:
return failed[6];
case REG_FAILED_FEATURE_RESULT:
return failed[7];
case BRIDGE_FAILED_FEATURE_RESULT:
return failed[8];
default :
throw new Exception("Attempt to access invalid result type! Use the Result Constants to avoid this error!");
}
}
/**
* Returns the value next to the specified result.
*/
public String getAdjacentValue(byte result) throws Exception{
if(result >= 0 && result < retrievedData.length - 1)
return retrievedData[result + 1];
else throw new Exception("Error! Attempt to access column with either no adjacent value or outside of data-range!");
}
/**
* Simply returns a String representing the date for each value in this class.
*/
@Override
public String toString(){
String temp = "";
for(String element : retrievedData){
if(element.toString() != retrievedData[retrievedData.length - 1])
temp += element + ", ";
else temp += element;
}
return temp;
}
}[/code]
só que não sei como utilizar… alguem me pode ajudar?
Obrigado… estive parado durante 1.5 anos e estou muito enferrujado!