10
$\begingroup$

I'm handling some paragraphs encoded with Base64 from CSV file format. The problem is that Mathematica can't decode it. I'm thinking to write my decode method by my own, but I ask it first.

By example:

I used base64.b64encode on python with the string:

s = '"Hola los felicito por su equipo de comunicadores. Me encanta verlos pues ustedes se salen de las   simplezas y superficialidades de los noticieros tradicionales.Un saludo desde Montreal- Canada.

Adelante! así como van en poco tiempo tendrán muchos mas seguidores que  la ""Gran prensa Colombiana"" la cual ha venido mintiendo por décadas.

"'

And outcome:

 b = 'IkhvbGEgbG9zIGZlbGljaXRvIHBvciBzdSBlcXVpcG8gZGUgY29tdW5pY2Fkb3Jlcy4gT\
WUgZW5jYW50YSB2ZXJsb3MgcHVlcyB1c3RlZGVzIHNlIHNhbGVuIGRlIGxhcyAgIHNpbXB\
sZXphcyB5IHN1cGVyZmljaWFsaWRhZGVzIGRlIGxvcyBub3RpY2llcm9zIHRyYWRpY2lvb\
mFsZXMuVW4gc2FsdWRvIGRlc2RlIE1vbnRyZWFsLSBDYW5hZGEuCgpBZGVsYW50ZSEgYXP\
DrSBjb21vIHZhbiBlbiBwb2NvIHRpZW1wbyB0ZW5kcsOhbiBtdWNob3MgbWFzIHNlZ3VpZ\
G9yZXMgcXVlICBsYSAiIkdyYW4gcHJlbnNhIENvbG9tYmlhbmEiIiBsYSBjdWFsIGhhIHZ\
lbmlkbyBtaW50aWVuZG8gcG9yIGTDqWNhZGFzLgoKIg=='

On Mathematica:

enter image description here

enter image description here

But if you use another base64 decoder like decoderb64, it can do the job.

$\endgroup$

1 Answer 1

13
$\begingroup$

That's because "Base64" is not a format but an encoding and you still need to tell Mathematica what format to import after decoding from Base64. This is described in the documentation.

Try this:

ImportString[s, {"Base64", "String"}]
$\endgroup$
2
  • $\begingroup$ Oh, Thanks, I don't figure out. I thought that "String" was implicit. $\endgroup$ Apr 3, 2014 at 14:45
  • 2
    $\begingroup$ @d555 It could be anything, not just String. Base64 is considered an encoding just like gzip (which is also supported). Any file in any format can be encoded like this. $\endgroup$
    – Szabolcs
    Apr 3, 2014 at 14:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.