I have many of csv & xls files, each contains a tabular data with coordinates (X,Y,Z, Lat, long,pointid, commnet1,...etc). The problem is that data and header names are messy, some X readings might be under "PointId" column or under any other column,..etc Y might be same,..etc, headers are not unique as well. The good thing is that I know the range values of X, Y readings wich are quite recognized in the tables. Z value comes directly after Y in the next column.
I need a script read each line in the messy csv or xls files and copy records data a new csv file (all in one csv file), the new file shall contain well organized data, additionally I want to have the file name of each record displayed in a new column in the new csv file.