Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
For each cell in the table, count the number of items in the same column with that value, and divide by the total number of items in the colum. Call this the cells 'value cardinality'. Next determine a type for every cell (int, float, string, path, filename, whatever you think you are likely to find). Like before count the number of cells in the same column with the same type, and divide it by the total number of items in the column. This gives a cells 'type cardinality'. Next for each row, multiple all the value cardinalities in that row, giving you a total value cardinatlity for that row. Do the same for type cardinality. Finally, check if either the value or type cardinality of the first row is an outlier compare to all the other rows. This can either be a simple check such as either of the values being the lowest, or a more complicated check (such as not only being the lowest value but also being at least 1 standard deviation away from the nearest value when compared to the distribution of cardinality values for the other rows). So if you have a table with headers like "Firstname","Lastname","Age", then the type cardinatlity will trigger because of the type difference in age. And if you have a table like "Firstname","Lastname","Sex", then the value cardinality will trigger. The hard situation is when you have a header like "Firstname,Middlename,Surname". This is where your success depends entirely on how how much effort you put into type identification - because that is how a human does it. In reply to Re: Useful heuristics for analyzing arrays of data to determine column header
by sectokia
|
|