Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

everyone, I'm handling some paragraphs enconded with Base64 from CSV file format. The problem is that Mathematica can't decode it. It seems Mathematica Encode/Decode their own Base64. I'm thinking 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.

Thanks in advance,

share|improve this question
up vote 6 down vote accepted

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"}]
share|improve this answer
    
Oh, Thanks, I don't figure out. I thought that "String" was implicit. – jonaprieto Apr 3 '14 at 14:45
    
@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. – Szabolcs Apr 3 '14 at 14:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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