Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi my fellows,
i have a qvd generater that load a lot of csv files to build my datamodel. Recently we got a new column in the csv files that named "indicator".
The old csv file must anyhow also be load with the updated csv file.
year_2009.csv file contains example these columns: name, surname, age
year_2010.csv file contains these new added colum: indicatior
If the script loads the csv files together, it breaks down. How can i load the csv without an Error ?
I Thought like this: If the column indicator exists then write the content. If not then write the column with the value( ' n.A ' )
HEL_DATA:
LOAD
name AS Namen,
surname AS Vornamen,
age AS Alter,
if (indicator >= 0 , indicator, 'n.A') ???
FROM year*.csv (utf8, txt, delimiter is ';', embedded labels, msq);
How can i realize that ?
Thank you very much.
Best regards
Hi
You shouldn't have any problems with that script - there is an example in the ZIP file that loads from two CSvs with the same columns as your original post. The only change is that the delimiter is a comma, rather than a semi-colon.
Jonathan
Hi there, you can use explicit concatenation to force QlikView to concatenate the cvs files eventhough they dont have the same structure. Please have a look to the attach qvw for better idea.
Regards
Hi Ivan,
thank you for your help. But can i do that not during the load process ?
Thank you
I dont thik I understood your question, you can do that anywhere you want as long as it is in the script.
Regards
Hi
I think something like this should work. Note the chnage to the from line. This to prevent reading the labels from the file which will cause an error for the year2009.csv fie.
DATA:
LOAD @1 AS Namen,
@2 AS Vornamen,
@3 AS Alter,
If(Len(@4) = 0, 'NA', @4) AS Indicator
FROM year*.csv (utf8, txt, delimiter is ';', no labels, msq, header is 1 lines);
Jonathan
Hi Jonathan,
i think you have the closest approch for my problem. The solution is near.
I want to load both files ( year_2009.csv , year_2010.csv) with one FROM command. Unfortunately the script above aborts, cause the first loaded year_2009.csv does not contain the column @4. Therfore i need something like a definition of cases.
case 1: if the column @4 does not exists ( example of the file 'year_2009.csv'), create a column @4 with the value 'nA'
case 2: if the column @4 exists ( example of the file 'year_2010.csv'), write the value as business as usual.
Thank you very much !
Hi
You shouldn't have any problems with that script - there is an example in the ZIP file that loads from two CSvs with the same columns as your original post. The only change is that the delimiter is a comma, rather than a semi-colon.
Jonathan
Hi Jonathan,
thank you very much for your help. The source csvfile must be the problem. I upload my csv file.
Thank you again.