Sounds like mime-type returned by server is application/octet-stream, so 
response is a bytearray, not a string.

Which means you pretty much has to cross your fingers and hope it's pure ascii, 
or consult an API document somewhere to find what encoding the data is actually 
in.
Luckily, in the sample case, it looks like it might be utf8 -

url := 'https://github.com/sudar/pig-samples/raw/master/data/tweets.csv'.
string := ZnCharacterEncoder utf8 decodeBytes: urlAsString asUrl 
retrieveContents.

will usually raise an error if it's not ;) (and it doesn't)

Cheers,
Henry

> On 09 May 2016, at 8:06 , Alexandre Bergel <[email protected]> wrote:
> 
> The following script still raises an error… No idea why…
> 
> 
> urlAsString := 
> 'https://github.com/sudar/pig-samples/raw/master/data/tweets.csv'.
> (NeoCSVReader on:  readStream)
>                               skipHeader;
>                               upToEnd.
> 
> Apparently SmallInteger>>codePoint does not exist...
> 
> Cheers,
> Alexandre
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
> 
> 
> 
>> On May 9, 2016, at 11:49 AM, Sven Van Caekenberghe <[email protected]> wrote:
>> 
>> 
>>> On 09 May 2016, at 16:29, Alexandre Bergel <[email protected]> wrote:
>>> 
>>> Oops… You’re right.
>>> Sorry about that
>> 
>> No problem.
>> 
>> Actually, many people use ZnEasy because it seems simple, but it can be 
>> deceiving (like in this case).
>> 
>> If you want the shortest possible code in scripting I would suggest doing it 
>> like this:
>> 
>> 'http://bit.ly/exampleCSV' asUrl retrieveContents.
>> 
>> 'http://zn.stfx.eu/zn/numbers.txt' asUrl retrieveContents.
>> 
>> The #retrieveContents message will fail unless there is a proper HTTP 200 OK 
>> response. And it is all cool unary messages !
>> 
>>> Alexandre
>>> --
>>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>>> Alexandre Bergel  http://www.bergel.eu
>>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>> 
>>> 
>>> 
>>>> On May 9, 2016, at 10:28 AM, Sven Van Caekenberghe <[email protected]> wrote:
>>>> 
>>>> 
>>>>> On 09 May 2016, at 15:26, Alexandre Bergel <[email protected]> 
>>>>> wrote:
>>>>> 
>>>>> Hi Sven,
>>>>> 
>>>>> There is apparently a problem in NeoCSVReader. #codepoint is apparently 
>>>>> missing
>>>>> The following code raises an exception:
>>>>> 
>>>>> urlAsString := 'http://bit.ly/exampleCSV'.
>>>> 
>>>> Can you give me a working URL so that I can try myself ?
>>>> 
>>>>> content := (ZnEasy get: urlAsString) contents readStream.
>>>>>           lines := (NeoCSVReader on: content)
>>>>>                                           skipHeader;
>>>>>                                           upToEnd.
>>>>> 
>>>>> 
>>>>> I loaded NeoCSV using:
>>>>>   Gofer new
>>>>>           smalltalkhubUser: 'SvenVanCaekenberghe' project: 'Neo';
>>>>>           package: 'ConfigurationOfNeoCSV'; load.
>>>>>   (Smalltalk at: #ConfigurationOfNeoCSV) loadBleedingEdge.
>>>>> 
>>>>> Any idea?
>>>>> 
>>>>> Cheers,
>>>>> Alexandre
>>>>> --
>>>>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>>>>> Alexandre Bergel  http://www.bergel.eu
>>>>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 
> 

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to