Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
naziralala
Creator
Creator

CSV File Leading Zeros and 0 in display

Hi All,

I am faced with a new challenge.

My leading 0's, example- 005678 is being seen in my output csv file written by sql script as 5678.

Also, if the amount is 0, it does not display the same, the field is empty.

Please assist with an example in sql code to resolve the same.

Thanks in advance. !

15 Replies
naziralala
Creator
Creator
Author

Yes. That is correct.

So, what is the solution?

Thanks.

Nazira

jeroen_wagner
Partner - Creator
Partner - Creator

This might help you: (see attached document)

jeroen_wagner
Partner - Creator
Partner - Creator

Did this help naziralala‌ ?

If so, please mark as correct / helpfull 🙂

naziralala
Creator
Creator
Author

No. It has not solved the issue.

Thanks.

jeroen_wagner
Partner - Creator
Partner - Creator

In what sense didn't it work?

Have you implemented the code I sended?

Perhaps an idea to share your app, so we can give you better support...?

naziralala
Creator
Creator
Author

Yes. i implemented the code, but the output did not change. In my case, it does not work.

When I tried using

'="'&[Code]&'"' as [Code]

it gives me the leading 0's but the other fields do not display correctly.

I am trying to get a csv file as output. My code is below:

[SGroup]:

LOAD

  [A Code],

  [Dep Year] as [Travel Year],

  [Book Date] as [G Booking Date],

  GuFlag as GFlag,

  [Group] as [G Group],

  [G Total Price]  as [Total Price]

  Resident [Creator]

  Where GuFlag='Y' and match(left([A Code],1),'0', '1', '2');

left Join ([SGroup])

LOAD

  

  [A Code],

  [G Group Name] as [GroupNme]

  Resident Light;

//Output Calculation By Group

Let vCurrYear=Year(Today()); //2016

[OutpuGGroup(2015 and 2016)] :

LOAD

  [A Code],

  [GroupNme] as [GroupName],

  [G Group] as [GGroup] ,

  [A Code]&'-'&[GroupNme]&'-'&[G Group] as Key,

  sum([Total Price]) as [CYBookingR]

Resident [SGroup]

  WHERE [Travel Year] = $(vCurrYear)  //2016

  Group By [A Code],[GroupNme],[G Group]; 

Let vCurrYear=($(vCurrYear)-1); //2015

Join ([OutpuGGroup(2015 and 2016)])

       

Load [A Code],

  [GroupNme] as [GroupName],

  [G Group] as [GGroup] ,

  [A Code]&'-'&[GroupNme]&'-'&[G Group] as Key,

  sum([Total Price]) as [PYBookingR]

Resident [SGroup]

WHERE [Travel Year] = $(vCurrYear) //2015

   

    Group By [A Code],[GroupNme],[G Group];

Gout:

Load    //'="'&[A Code]&'"' as [A Code],

[A Code],

  //'="'&[GroupName]&'"' as [GroupName],

  [GroupName],

  //="'&[GGroup]&'"' as [GGroup],

  [GGroup],

  //'="'&Key&'"' as Key,

  Key,

  if(IsNull([PYBookingR]),0,[PYBookingR]) as [B.PYBooking R],

  if(IsNull([CYBookingR]),0,[CYBookingR]) as [B.CYBooking R]

Resident [OutpuGGroup(2015 and 2016)] ;

left join

Load    //'="'&[A Code]&'"' as [A Code],

[A Code],

  //'="'&[GroupName]&'"' as [GroupName],

  [GroupName],

  //="'&[GGroup]&'"' as [GGroup],

  [GGroup],

  //'="'&Key&'"' as Key,

  Key,

      

        num(if([B.PYBooking R]= 0 and [B.CYBooking R]=0,0,

         if([B.PYBooking R]<> 0, [B.CYBooking R]/[B.PYBooking R]-1, 1.00)),'#,##0.00') as [B.YOY R]

  Resident Gout ;

Drop Table [OutpuGGroup(2015 and 2016)];

Drop field Key from Gout;

//Store '="'&[A Code]&'"' as [A Code],

Store [A Code],

  [GroupName],

  [GGroup],

  [B.PYBooking R] as [PYBooking R],

      

        [B.CYBooking R] as [CYBooking R]

       

//Store *

From Gout

INTO [$(vOutfile2016)](txt);

Drop Table Gout;

Drop Table [SGroup];