0
I developed a program that stores a list of ids, so
But for the desired purpose, the data should take the sequential form, so that the first pair of ids is something like: "889926212541448192" becomes 1 and "889919950248448000" becomes 2. That is, the file to be obtained should be something like:
Where the first id connects with 2,3 and 6, and the id 4 only with the 5, forming a network.
I have no experience in this area, but I can’t find a way to do this reading.
I tried to make some programs, but they read only row and not column id to id. This data is saved by following the following program
import json
Arq = open('ids.csv','w') Arq.write('Source'+','+'Target') Arq.write(" n")
list network = [] #list to store all ids
with open('dados_twitter.json', 'r') as f:
for line in f:
lista = []
tweet = json.loads(line) # reescreve como um dicionário Python
lista = list(tweet.keys()) #escreve lista das chaves
try:
if 'retweeted_status' in lista:
id_rt = json.dumps(tweet['retweeted_status']['id_str'])
id_status = json.dumps(tweet['id_str'])
lista_rede.append(tweet['id_str'])
lista_rede.append(tweet['retweeted_status']['id_str'])
arq.write( id_status +','+ id_rt )
arq.write("\n")
if tweet['quoted_status'] in lista :
id_rt = json.dumps(tweet['quoted_status']['id_str'])
id_status = json.dumps(tweet['id_str'])
lista_rede.append(tweet['id_str'])
lista_rede.append(tweet['quoted_status']['id_str'])
arq.write( id_status +','+ id_rt )
arq.write("\n")
except:
continue
Arq.close()
As a result I have a file with the ids data in pairs of interactions
How can I rearrange this data in reading, or even writing it?? In python or in another language?
Please do not put the codes as image, the site has support for them. Edit the question and enter them correctly.
– Woss