Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
icaro_povoa
Contributor II
Contributor II

How to add columns

Dear all,

I am starting to create scripts with multiple sources, and noticed that some columns are not available in all the tables.

Is it possible to add columns directly in the script and fill them with a standard criteria without changing my data source?

I need to have things as Crop/Country/Season as a filter, but do not have all of them listed in some of my sources.( Because I have one file for each Crop/Country/Season)

Thank you very much

5 Replies
sunny_talwar

Are they going to be static for all rows? or a condition based? You can use Mapping Load with ApplyMap() to be able to do this based on condition. For more help, please provide a sample.

Best,

Sunny

icaro_povoa
Contributor II
Contributor II
Author

Hi Sunny,

Yes they will be static. I need to create the column because I have 3 files.

- The first one I have a lot of information inclusive the column called CROP ( Corn and Sunflower)

- The second file is basically a database from my Corn team, so I only have information of corn, so we didn´t add the column "Crop" ( because will make no sense once we just have one crop)

- The third file is the same as corn, but for Sunflower.

What I need is to add on the files 2 and 3 the column CROP filled with Corn (File2) and Sunflower (File3), so I can create a script with the 3 files and use this column as a filter.

Hope it helps.

Thanks

sunny_talwar

For static stuff, you can do this:

LOAD FieldName,

          'Corn' as Crop

FROM Source1;

LOAD FieldName,

          'Sunflower' as Crop

FROM Source2;

icaro_povoa
Contributor II
Contributor II
Author

Should I add  this inside my current script from the Source 1? or Should I add this in the end of my scrip?

Like this??

LOAD

    

      Country,

     [Production Season] as ProductionCycle,

     Field as PlotName2,

     [Field Manager],

     Supervisor,

     FieldName,

          'Corn' as Crop

FROM Source 1

or like this ????

LOAD

    

     Country,

     [Production Season] as ProductionCycle,

     Field as PlotName2,

     [Field Manager],

     Supervisor    

FROM Source 1

LOAD FieldName,

          'Corn' as Crop

FROM Source1;

Thanks

sunny_talwar

First way:

LOAD

      Country,

     [Production Season] as ProductionCycle,

     Field as PlotName2,

     [Field Manager],

     Supervisor,

     FieldName,

          'Corn' as Crop

FROM Source 1