internet-sicherheit / ethereum-cache-creator

GNU General Public License v3.0
0 stars 0 forks source link

Import data into Python/R and use data science libs for analysis #5

Closed beeshot closed 4 years ago

Mschnuff commented 4 years ago
  # install lib
  if (!suppressWarnings(require(rjson))) install.packages("rjson")
  if (!suppressWarnings(require(igraph))) install.packages("igraph")
  if (!suppressWarnings(require(dplyr))) install.packages("dplyr")
  if (!suppressWarnings(require(jsonlite))) install.packages("jsonlite")

  library("rjson")
  library("igraph")
  library("dplyr")
  library("jsonlite")

  #import json file from local machine

  json_file <- "~/blockchain/rstudio/trans.json"

  json_data <- jsonlite::fromJSON( json_file )
  summary(json_data)

  transaction <- data.frame(
    from=c (json_data$fromAddress),
    to=c (json_data$toAddress)
  )

  network <- graph_from_data_frame(d=transaction, directed=F)
  deg <- degree(network, mode="all")
  plot(network, vertex.size=deg*6, vertex.color=rgb(0.1,0.7,0.8,0.5) )
Mschnuff commented 4 years ago

file path needs to be adjusted according to your folder structure. it seems jsonlite automatically flattens the lists and replaces null values with NA

kiview commented 4 years ago

Closed by #11.