Hi Charles,

Sorry for the bad advice :)

I think you might want to step back one step. This command:

julia> myportfolio = readdlm("./portfolio.txt",'\n')

might not be what you want. Look at 

julia> which(readdlm,(ASCIIString,Char))
readdlm(input, dlm::Char) at datafmt.jl:37

It looks like you are making '\n' a delimiter, when it should probably just 
be the end of line (eol). You might try readcsv or maybe even readtable 
instead. I don't think you want to end up with a matrix of SubStrings. If 
you do, then Seth's solution is perfect :)


On Saturday, December 5, 2015 at 9:57:32 AM UTC+8, Charles Santana wrote:
>
> Here it is late, so of course I forgive you the typo! :) But many thanks 
> for the TIP! :)
>
> However, it doesn't seem to work here. My problem was that my matrix was 
> composed by SubString{ASCIIString}. So, if I call typeof(myportfolio[1]) I 
> get:
>
>         julia> typeof(myportfolio[1])
>         SubString{ASCIIString}
>  
> And the same if I call typeof(myportfolio[1,1]):
>
>         julia> typeof(myportfolio[1,1])
>         SubString{ASCIIString}
>
> Could you please send the result of typeof(myportfolio[1]) in your 
> example? I suppose it would be an ASCIIString. 
>
> Seth's suggestion worked fine for me. To use a cast to ASCIIString to 
> convert myportfolio[1], like this:
>
>         julia> typeof(ASCIIString(myportfolio[1]))
>         ASCIIString
>
> But thanks anyway! 
>
> Best,
>
> Charles
>
>
> On 5 December 2015 at 01:46, Eric Forgy <[email protected] <javascript:>> 
> wrote:
>
>> It's early and I didn't finish my first cup of coffee yet, so forgive the 
>> typo :)
>>
>> julia> myportfolio
>> 1x1 Array{Any,2}:
>>  "GOOG/NASDAQ_GOOG"
>>
>> julia> myportfolio[1,1]
>> "GOOG/NASDAQ_GOOG"
>>
>> julia> typeof(myportfolio[1,1])
>> ASCIIString
>>
>>
>> On Saturday, December 5, 2015 at 8:38:05 AM UTC+8, Eric Forgy wrote:
>>>
>>> Hi Charles,
>>>
>>> myportfolio is a Matrix, i.e. Array{Any,2}, so you need two indices to 
>>> access it:
>>>
>>> julia> myportfolio
>>> 1x1 Array{Any,2}:
>>>  "GOOG/NASDAQ_GOOD"
>>>
>>> julia> myportfolio[1,1]
>>> "GOOG/NASDAQ_GOOD"
>>>
>>> julia> typeof(myportfolio[1,1])
>>> ASCIIString
>>>
>>> Best regards,
>>> Eric
>>>
>>> On Saturday, December 5, 2015 at 6:59:41 AM UTC+8, Charles Santana wrote:
>>>>
>>>> wow! That simple! Yes it works!
>>>>
>>>> Thanks, Seth!
>>>>
>>>> Charles
>>>>
>>>> On 4 December 2015 at 23:53, Seth <[email protected]> wrote:
>>>>
>>>>> Maybe this will work for you?
>>>>>
>>>>> julia> a = "foobarbaz"
>>>>> "foobarbaz"
>>>>>
>>>>> julia> b = SubString(a,3,6)
>>>>> "obar"
>>>>>
>>>>> julia> typeof(b)
>>>>> SubString{ASCIIString}
>>>>>
>>>>> julia> c = ASCIIString(b)
>>>>> "obar"
>>>>>
>>>>> julia> typeof(c)
>>>>> ASCIIString
>>>>>
>>>>>
>>>>>
>>>>> On Friday, December 4, 2015 at 2:48:12 PM UTC-8, Charles Santana wrote:
>>>>>>
>>>>>> Hi people,
>>>>>>
>>>>>> Maybe it is a trivial question for most of you, but I really could 
>>>>>> not find a way to solve my problem.
>>>>>>
>>>>>> I am using the function quandlget(id::ASCIIString) from the library 
>>>>>> https://github.com/milktrader/Quandl.jl (a great contribution, by 
>>>>>> the way!)
>>>>>>
>>>>>> Everything works fine when I use it in a straightforward way:
>>>>>>
>>>>>> julia> mydat = quandl("GOOG/NASDAQ_GOOG",rows=100,format="DataFrame")
>>>>>> 100x6 DataFrames.DataFrame
>>>>>> | Row | Date       | Open   | High   | Low    | Close  | Volume    |
>>>>>> |-----|------------|--------|--------|--------|--------|-----------|
>>>>>> | 1   | 2015-07-08 | 521.05 | 522.73 | 516.11 | 516.83 | 1.2967e6  |
>>>>>> | 2   | 2015-07-09 | 523.12 | 523.77 | 520.35 | 520.68 | 1.84235e6 |
>>>>>> | 3   | 2015-07-10 | 526.29 | 532.56 | 525.55 | 530.13 | 1.95668e6 |
>>>>>>
>>>>>>
>>>>>> or when I do:
>>>>>>
>>>>>> julia> myid = "GOOG/NASDAQ_GOOG"
>>>>>> "GOOG/NASDAQ_GOOG"
>>>>>>
>>>>>> julia> typeof(myid)
>>>>>> ASCIIString
>>>>>>
>>>>>> julia> mydat = quandl(myid,rows=100,format="DataFrame")
>>>>>> 100x6 DataFrames.DataFrame
>>>>>> | Row | Date       | Open   | High   | Low    | Close  | Volume    |
>>>>>> |-----|------------|--------|--------|--------|--------|-----------|
>>>>>> | 1   | 2015-07-08 | 521.05 | 522.73 | 516.11 | 516.83 | 1.2967e6  |
>>>>>> | 2   | 2015-07-09 | 523.12 | 523.77 | 520.35 | 520.68 | 1.84235e6 |
>>>>>> | 3   | 2015-07-10 | 526.29 | 532.56 | 525.55 | 530.13 | 1.95668e6 |
>>>>>>
>>>>>>
>>>>>> However, I get an error when I read my data from an external file. 
>>>>>> Assume I have an ascii file containing only one line:
>>>>>>
>>>>>> $ echo "GOOG/NASDAQ_GOOG" > portfolio.txt
>>>>>>
>>>>>> $ cat portfolio.txt 
>>>>>> GOOG/NASDAQ_GOOG
>>>>>>
>>>>>>
>>>>>> I just read the content of this file by using readdlm and try to use 
>>>>>> it to call the same function quandl, but it does not work.
>>>>>>
>>>>>> julia> myportfolio = readdlm("./portfolio.txt",'\n')
>>>>>> 1x1 Array{Any,2}:
>>>>>>  "GOOG/NASDAQ_GOOG"
>>>>>>
>>>>>> julia> typeof(myportfolio[1])
>>>>>> SubString{ASCIIString}
>>>>>>
>>>>>> julia> mydat = quandl(myportfolio[1],rows=100,format="DataFrame")
>>>>>> ERROR: MethodError: `quandlget` has no method matching 
>>>>>> quandlget(::SubString{ASCIIString})
>>>>>>
>>>>>>
>>>>>> I suppose the easiest way to solve this problem is to convert my 
>>>>>> SubString{ASCIIString} variable to ASCIIString. Am I right here? How can 
>>>>>> I 
>>>>>> do it?
>>>>>>
>>>>>> Does any of you have another suggestion? May be I could read my data 
>>>>>> in a different way instead of using readdlm? 
>>>>>>
>>>>>> Thanks for any tip!
>>>>>>
>>>>>> best,
>>>>>>
>>>>>> Charles
>>>>>> -- 
>>>>>> Um axé! :)
>>>>>>
>>>>>> --
>>>>>> Charles Novaes de Santana, PhD
>>>>>> http://www.imedea.uib-csic.es/~charles
>>>>>>
>>>>>
>>>>
>>>>
>>>> -- 
>>>> Um axé! :)
>>>>
>>>> --
>>>> Charles Novaes de Santana, PhD
>>>> http://www.imedea.uib-csic.es/~charles
>>>>
>>>
>
>
> -- 
> Um axé! :)
>
> --
> Charles Novaes de Santana, PhD
> http://www.imedea.uib-csic.es/~charles
>

Reply via email to