Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
Please check my xls file :
I want to concatenate several tables determining the header depending the file name and the theorical header Name
Can you help me on this ?
Thanks
Thanks agin for your help, but not sure to understand your point. Here is an example of what I want to do :
Table1 | |||||
PU | CC | Group | User | File | |
15 | 152 | G1 | Table1 | ||
12 | 152 | Adupont | Table1 | ||
Table2 | |||||
PU | CostCenter | Group | User | File | |
22 | 152 | G3 | Table2 | ||
11 | 152 | Alefebvre | Table2 | ||
Alias Table | |||||
TableName | Name | UniqueName | |||
Table1 | PU | Parent.PU.UniqueName | |||
Table1 | CC | CC.UniqueName | |||
Table1 | Group | Group | |||
Table1 | User | User | |||
Table2 | PU | PU.UniqueName | |||
Table2 | CostCenter | CC.UniqueName | |||
Table2 | Group | Group | |||
Table2 | User | User | |||
Table3 | Montant | Total.Amount | |||
Table3 | OI | OI.UniqueName | |||
Table3 | List | ApproverList | |||
Result | |||||
Parent.PU.UniqueName | PU.UniqueName | CC.UniqueName | Group | User | File |
22 | 152 | G3 | Table2 | ||
11 | 152 | Alefebvre | Table2 | ||
15 | 152 | G1 | Table1 | ||
12 | 152 | Adupont | Table1 |
To conclude: you are starting with a pre-load containing file/table/field-information which are read and prepared to define ALIAS strings and maybe also other load-information, like field-lists, where-clauses, what ever.
Some of them like the ALIAS may be applied before the real file-loading is performed but if any of these information isn't globally true else depending on current file/table you will need to detect which file/table is the current one and then providing the specialized information. And for such a task you will need any kind of loop and within it measures to detect/extract which is the current one and then providing the right information.
I'm not sure if I understand what's exactly the problem. If it's related to the ALIAS which might be differentiated in some way you may need to apply it multiple times. I think it's rarely used and I do not remember of having seen a way to remove/disable/revert the statement directly but I think it could be overwritten with new definitions - and in such case you may need to use a filelist-loop and doing the needed work within it.
Beside this I suggest to consider to simplify the approach by loading a file and applying the wanted renaming and then storing it as qvd and dropping the file and going then to the next file. Afterwards all the qvd's could be loaded again.
To sumup : I want to apply a specific ALIAS depending on the file I'm loading.
In my example, for Table1 we must have ALIAS "PU" as "Parent.PU.UniqueName" and for Table2 we must have ALIAS "PU" as "PU.UniqueName". So, my idea was to prefix all "old headers" with the filename and then to concatenate my paramter fields to use : ALIAS "Table1PU" as "Parent.PU.UniqueName" and ALIAS "Table2PU" as "PU.UniqueName".
Do you think there is a simplier way ?
Thanks again ! really appreciate your help
I think the above mentioned approach of loading each single file + applying the transformation and storing it + dropping the table and then going to the next file is the most simple approach. You wouldn't need the ALIAS else you could apply a renaming per mapping - and you would have all files as qvd's.
Ok, will try, what do you think is the simpliest way ?
I have a folder in which I want to load all files (never know wich ones) and for all files, I want to load all fields (nerver know which ones) and rename its
Like always there is no generally simplest approach else it will depend on various factors which way is more suitable as the others. Further there must be always some information/rules/condition which kind of data exists and what should happens with them - maybe not complete ones at this stage but for the following stages. To not considering the later requirements is surely possible but it may lead to more efforts and complexity within the following layers and the overall efforts might be not optimal.
Assuming that really no valid information exists about these files I would just load them + collecting some meta-information and storing them as qvd-files without any transformation - means also no renaming. For this I would apply a filelist-loop like hinted above and loading all fields with a wildcard. Further I would add path + filename information extracted from the iterator-variable or per functions like filename() respectively if there are further information encoded like YYYYMM periods or any kind of categories/countries or whatever and then also adding the filetime() and filesize() - and using those information to decode the qvd-filenames.
Afterwards you would be able to extract many of these information without loading the file again. Of course accessing the encoded information from the filename is simple but qvd's allow also a read of various meta-information like the qvdnooffields() or qvdnoofrecords() without a load.
Of course more is possible if you creates at ones a meta-table within the loop directly after the file-load, like:
Meta: load '$(file)' as File, now() as LoadTime, .... autogenerate 1;
which is later also saved as qvd. Each interesting kind of information could be saved there like a list of the fields, formatting and NULL information and ... Further these information might be used to categorize the files in different types which you also may encode within the qvd-name.
In the next layer you could then loop through such meta-table and matching those information with a certain set of rules to perform the needed transformation.