Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Reko_freed
Contributor III
Contributor III

Use alias name while loading a data for all the columns

I am trying to load  few files they are file A and file B for two years that is 2019 and 2020, and they are basically - file_2020_A, file_2019_A, file_2020_B, file_2019_B. The load script which I am using is
[a]:
LOAD *
FROM [filepath/*_A.csv]

[b]:
LOAD*
FROM [filepath/*_B.csv]

what I want is at the time of data loading it will add a suffix at the end of each and every column for all the files.

for e.g., - file A consist of column col1, col2, col3... it will be change to col1_a, col2_a, col3_a and simultaneously for b as well.

please suggest me the change in the existing load script so that I get my result.

 

 

 

Labels (2)
3 Replies
Lauri
Specialist
Specialist

I would:

  1. Get the suffix from the file name during the initial load and store it in a temporary table along with the table name
  2.  Loop through the field names of each table and run a rename statement where you add the suffix

 

Or
MVP
MVP

As a potential easier alternative, you could use Qualify *; to generate an automatic prefix (not suffix) of the table name.

Reko_freed
Contributor III
Contributor III
Author

I have tried Qualify, but let me tell you what issue I am facing,  it creates four different suffix names for four different files, due to which I am not able to get a concatenated table(one below other). See my load script, 

[a]:
LOAD *
FROM [filepath/*_A.csv   
this will load the file name ending with 'A' and concat them and gives me a single file for A
what I want is  -  filename ending with 'A' the prefix/suffix should be same