1
我的格式爲csv文件:CSV成JSON轉換
"","Sequence","Paths","sequence_length"
"1","Social -> Social -> Social -> Social -> Social -> Social -> Social -> Social",29,8
"2","Social -> Social -> Social -> Social -> Social -> Social -> Social",30,7
"3","Social -> Social -> Social -> Social -> Social -> Social",40,6
"4","Social -> Social -> Social -> Social -> Social",71,5
"5","Social -> Social -> Social -> Social",156,4
"6","Social -> Social -> Social",273,3
"7","Social -> Social -> SEO",40,3
"8","Social -> Social",729,2
"9","Social -> SEO -> Social",51,3
"10","Social -> SEO",180,2
"11","Social -> SEM",56,2
我打算將它轉換成JSON樹層次結構如下:
"Root" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"children" : [
{
"Sequence" : "Social",
"Path" : 29}],
}
}
如果每個觸摸點即。在每行的CSV文件中用 - >表示的'Social'表示前一個的孩子,並且路徑被添加到最後一個節點。
我試圖在一個陣列中的社會分裂的事情作爲
data.forEach(function(d){
var x = d.Sequence.split(' -> ');
,然後使用這張X解析成JSON.Could請人幫我it.Thanks!
你如何調用該函數? – Guybrush
當執行匿名函數時返回'undefined'。您可能想要在匿名函數中返回函數以在下次執行它。 –
@Guybrush。 self.createIframe(URL); –