Hello !
I am relatively new in the Julia world, but it appears to be a cool language I work with more and more.
I encounter an issue that Google and Wikis hasn’t been able to resolve ; maybe this is really easy, but I am coming from PHP and some concepts are hard to fit in my brain.
In the example case I describe to you, here’s the issue :
I have a file with 40000 CSV lines, where every line is divide in different columns :
79373,37336,something,here,also,again
To manage these 40000 lines, I would like to run a loop on them, using eachline(). It works fine, I am now able to explode every single line using the split() function. But, for an easier understanding, I would like to change the key names from 1,2,3,4… to something more like “id”, “subscription”, creating a new variable.
In PHP, I would do something like this :
$elements = explode(",", $line)
$data = [
"id" => $elements[0],
"subscription" => $elements[1],
];
But in Julia, it appears impossible
data["id"] = elements[1]
ERROR: ArgumentError: invalid index: id
Stacktrace:
[1] setindex!(::Array{SubString{String},1}, ::SubString{String}, ::String) at ./abstractarray.jl:968
I heard about Dict(), but I cannot find any working method using it.
Do you have any idea how to do this kind of operations ?
Regards