You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@zeppelin.apache.org by Nikhil Utane <ni...@gmail.com> on 2017/06/21 04:46:10 UTC

Printing table with variables in pyspark

Hi,

The official documentation shows example of printing static values in a
table.
I have a need to print variable values inside table in pyspark.
How to achieve that?

%pyspark
str="Col1\tCol2"
print("%table %s" % str)

ValueError: unsupported format character 't' (0x74) at index 1

-Thanks & Regards
Nikhil

Re: Printing table with variables in pyspark

Posted by Nikhil Utane <ni...@gmail.com>.
Funny thing happened actually.
I had tried same way as above but removed additional content for simplicity.
I made the mistake of naming my variable as str (Duhh). This then overrode
the standard str() function and because of that whatever I tried failed.

After restarting the interpreter it all worked fine.

Thanks for your help.
-Nikhil

On Wed, Jun 21, 2017 at 1:22 PM, Jeff Zhang <zj...@gmail.com> wrote:

>
> This is not zeppelin issue, it is due to your python code, use following
> code
>
> str="Col1\tCol2"
> print("%table " + str)
>
>
>
> Nikhil Utane <ni...@gmail.com>于2017年6月21日周三 下午12:46写道:
>
>> Hi,
>>
>> The official documentation shows example of printing static values in a
>> table.
>> I have a need to print variable values inside table in pyspark.
>> How to achieve that?
>>
>> %pyspark
>> str="Col1\tCol2"
>> print("%table %s" % str)
>>
>> ValueError: unsupported format character 't' (0x74) at index 1
>>
>> -Thanks & Regards
>> Nikhil
>>
>

Re: Printing table with variables in pyspark

Posted by Jeff Zhang <zj...@gmail.com>.
This is not zeppelin issue, it is due to your python code, use following
code

str="Col1\tCol2"
print("%table " + str)



Nikhil Utane <ni...@gmail.com>于2017年6月21日周三 下午12:46写道:

> Hi,
>
> The official documentation shows example of printing static values in a
> table.
> I have a need to print variable values inside table in pyspark.
> How to achieve that?
>
> %pyspark
> str="Col1\tCol2"
> print("%table %s" % str)
>
> ValueError: unsupported format character 't' (0x74) at index 1
>
> -Thanks & Regards
> Nikhil
>