1

After running the below code i am getting only rows where is present and not the rows where just ID is present.

Is there any problem with the extraction of file.

DROP VIEW IF EXISTS dbo.Consolidated;
CREATE VIEW IF NOT EXISTS dbo.Consolidated
AS
EXTRACT Statement

FROM   "adl:///2016/08/12/File_name.csv"
USING Extractors.Csv(silent : true, quoting : true, nullEscape : "/N");

@Temp =
SELECT *
FROM Consolidated;


OUTPUT @Temp
TO "adl://arbit/new_cont_check.csv"
USING Outputters.Csv(); 
Bond
  • 101
  • 1
  • 3
  • 15
  • 1
    i am getting red line below OUTER keyword while running your code ..... – Bond Mar 30 '17 at 13:54
  • Have you accidentally added a semi-colon at the end of the first `EXTRACT` statement? – wBob Mar 30 '17 at 14:39
  • Hi, did you have any luck with this? – wBob Apr 03 '17 at 12:29
  • No... i haven't added any semi-colon at the end. Even if -else statements are not working in my Visual Studio. I think i have older version of Visual Studio. will update and check. – Bond Apr 04 '17 at 13:44

2 Answers2

2

So your number of columns vary? If yes, try using a user-defined extractor. An example of a user-defined extractor where the number of columns vary can be seen @ Using User-Defined Extractor - FlexExtractor.

1

You have added the silent: true argument to your USING clause meaning the EXTRACT will not fail or even complain if the rows don't quite match your schema definition. This is the intended behaviour and probably what you want for this example. In order to pick up the other rows, you can use OUTER UNION, like in this recent example:

Another working example similar to yours:

@input =
    EXTRACT ControllerID int?,
            ParameterID int?,
            MeasureDate DateTime,
            Value float
    FROM "/input/input56.csv"
    USING Extractors.Csv(silent : true, quoting : true, nullEscape : "/N", skipFirstNRows : 1)

    OUTER UNION ALL BY NAME ON ( ControllerID )

    EXTRACT ControllerID int?
    FROM "/input/input56.csv"
    USING Extractors.Csv(silent : true, quoting : true, nullEscape : "/N", skipFirstNRows : 1);


OUTPUT @input
TO "/output/output.txt"
USING Outputters.Tsv(quoting : false);

I used this sample file and got these results:

My Results with OUTER UNION

NB I have changed the nullability of your columns as otherwise the OUTER UNION add default values for the .Net types as per the Sep 2016 release notes.

Community
  • 1
  • 1
wBob
  • 13,710
  • 3
  • 20
  • 37