Thread overview
Array Printing
Sep 12
Vino.B
Sep 12
Vino.B
Sep 12
vino
September 12
Hi All,

 Request your help in printing the below array output as per the below required output

Array Output:
["C:\\Temp\\TEST2\\BACKUP\\dir1", "34", "C:\\Temp\\TEST2\\BACKUP\\dir2", "36", "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"]
["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34", "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"]
["C:\\Temp\\TEST2\\TEAM\\DND1", "34"]


Required output:
C:\Temp\TEST2\BACKUP\dir1			 	34
C:\Temp\TEST2\BACKUP\dir2 				36
C:\Temp\TEST3\BACKUP\\dir1 				69
C:\Temp\TEST2\PROD_TEAM\\dir1 			        34
C:\Temp\TEST2\PROD_TEAM\\DND1 			        34
C:\Temp\TEST2\TEAM\\DND1 	                        34

From,
Vino.B


September 12
On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote:
> Hi All,
>
>  Request your help in printing the below array output as per the below required output
>
> Array Output:
> ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34", "C:\\Temp\\TEST2\\BACKUP\\dir2", "36", "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"]
> ["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34", "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"]
> ["C:\\Temp\\TEST2\\TEAM\\DND1", "34"]
>
>
> Required output:
> C:\Temp\TEST2\BACKUP\dir1			 	34
> C:\Temp\TEST2\BACKUP\dir2 				36
> C:\Temp\TEST3\BACKUP\\dir1 				69
> C:\Temp\TEST2\PROD_TEAM\\dir1 			        34
> C:\Temp\TEST2\PROD_TEAM\\DND1 			        34
> C:\Temp\TEST2\TEAM\\DND1 	                        34
>
> From,
> Vino.B

Try this:

 writefln("%(%s\n%)", array);

See std.format's documentation for more
September 12
On Tuesday, 12 September 2017 at 07:28:00 UTC, Anton Fediushin wrote:
> On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote:
>> Hi All,
>>
>>  Request your help in printing the below array output as per the below required output
>>
>> Array Output:
>> ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34", "C:\\Temp\\TEST2\\BACKUP\\dir2", "36", "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"]
>> ["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34", "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"]
>> ["C:\\Temp\\TEST2\\TEAM\\DND1", "34"]
>>
>>
>> Required output:
>> C:\Temp\TEST2\BACKUP\dir1			 	34
>> C:\Temp\TEST2\BACKUP\dir2 				36
>> C:\Temp\TEST3\BACKUP\\dir1 				69
>> C:\Temp\TEST2\PROD_TEAM\\dir1 			        34
>> C:\Temp\TEST2\PROD_TEAM\\DND1 			        34
>> C:\Temp\TEST2\TEAM\\DND1 	                        34
>>
>> From,
>> Vino.B
>
> Try this:
>
>  writefln("%(%s\n%)", array);
>
> See std.format's documentation for more

Hi,

 Sorry, it didn't work, the genrated out is as below
Output:

"C:\Temp\TEST2\BACKUP\dir1"
"34"
"C:\Temp\TEST2\BACKUP\dir2" 				
"36"
"C:\Temp\TEST3\BACKUP\\dir1" 				
"69"
"C:\Temp\TEST2\PROD_TEAM\dir1" 			
"34"
"C:\Temp\TEST2\PROD_TEAM\DND1" 			
"34"
"C:\Temp\TEST2\TEAM\\DND1" 	
"34"

From,
Vino.B

September 12
On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote:
>  Request your help in printing the below array output as per the below required output

You can just loop over it and write the components with the tab separator. Did you try that?
September 12
On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote:
> Hi All,
>
>  Request your help in printing the below array output as per the below required output
>
> Array Output:
> ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34", "C:\\Temp\\TEST2\\BACKUP\\dir2", "36", "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"]
> ["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34", "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"]
> ["C:\\Temp\\TEST2\\TEAM\\DND1", "34"]
>
>
> Required output:
> C:\Temp\TEST2\BACKUP\dir1			 	34
> C:\Temp\TEST2\BACKUP\dir2 				36
> C:\Temp\TEST3\BACKUP\\dir1 				69
> C:\Temp\TEST2\PROD_TEAM\\dir1 			        34
> C:\Temp\TEST2\PROD_TEAM\\DND1 			        34
> C:\Temp\TEST2\TEAM\\DND1 	                        34
>
> From,
> Vino.B


You can also use leftJustifier (or the eager version, leftJustify) from std.string to make the output formatted like that :

import std.stdio;
import std.string;
import std.range;

void main()
{
	auto a1 = ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34", "C:\\Temp\\TEST2\\BACKUP\\dir2", "36", "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"];
	auto a2 = ["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34", "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"];
	auto a3 = ["C:\\Temp\\TEST2\\TEAM\\DND1", "34"];

	a1.print;
	a2.print;
	a3.print;
}

void print(string[] array)
{
	foreach(i; iota(0, array.length, 2))
		writeln(array[i].leftJustifier(60, ' '), array[i + 1]);
}

Output :

C:\Temp\TEST2\BACKUP\dir1                                   34
C:\Temp\TEST2\BACKUP\dir2                                   36
C:\Temp\TEST3\BACKUP\dir1                                   69
C:\Temp\TEST2\PROD_TEAM\dir1                                34
C:\Temp\TEST2\PROD_TEAM\DND1                                34
C:\Temp\TEST2\TEAM\DND1                                     34
September 12
On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote:
> Hi All,
>
>  Request your help in printing the below array output as per the below required output

As a fan of stuffing as much as possible into one line:
>void main()
>{   import std.stdio;
>    import std.range;
>    import std.algorithm.iteration;
>    auto a = ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34",
>        "C:\\Temp\\TEST2\\BACKUP\\dir2", "36",
>        "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"];
>    auto b = ["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34",
>        "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"];
>    auto c = ["C:\\Temp\\TEST2\\TEAM\\DND1", "34"];
>    chain(a, b, c).chunks(2).each!(e => writefln!"%-60s %s"(e[0], e[1]));
>}
September 12
On Tuesday, 12 September 2017 at 13:15:01 UTC, Vino.B wrote:
> Hi,
>
>  Sorry, it didn't work, the genrated out is as below

Oops, sorry. It should look like this:

writefln("%-(%s\n%)", array);


September 12
On Tuesday, 12 September 2017 at 13:55:17 UTC, lithium iodate wrote:
> On Tuesday, 12 September 2017 at 06:29:53 UTC, Vino.B wrote:
>> Hi All,
>>
>>  Request your help in printing the below array output as per the below required output
>
> As a fan of stuffing as much as possible into one line:
>>void main()
>>{   import std.stdio;
>>    import std.range;
>>    import std.algorithm.iteration;
>>    auto a = ["C:\\Temp\\TEST2\\BACKUP\\dir1", "34",
>>        "C:\\Temp\\TEST2\\BACKUP\\dir2", "36",
>>        "C:\\Temp\\TEST3\\BACKUP\\dir1", "69"];
>>    auto b = ["C:\\Temp\\TEST2\\PROD_TEAM\\dir1", "34",
>>        "C:\\Temp\\TEST2\\PROD_TEAM\\DND1", "34"];
>>    auto c = ["C:\\Temp\\TEST2\\TEAM\\DND1", "34"];
>>    chain(a, b, c).chunks(2).each!(e => writefln!"%-60s %s"(e[0], e[1]));
>>}

Hi,

Thank you very much the one liner worked fine.