-
Notifications
You must be signed in to change notification settings - Fork 2
/
addReTweetAndFav.py
46 lines (35 loc) · 1.02 KB
/
addReTweetAndFav.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
# Input file donde está la data.
ifile1 = open("datasets/dumpCaraotaDigitalCNNELaPatilla.csv", "rb")
reader1 = csv.reader(ifile1)
ifile2 = open("datasets/datos_separados/featureVectorsEntrenamientoWithTopic.csv", "rb")
reader2 = csv.reader(ifile2)
# Output file donde se almacenará los datos de cada topico.
ofile = open("datasets/datos_separados/featureVectorsEntrenamientoWithTopicRetuitFav.csv", "wb")
writer = csv.writer(ofile, delimiter=',')
conRetuitsFav = []
for row in reader1:
conRetuitsFav.append(row)
conTopic = []
for row in reader2:
conTopic.append(row)
ifile1.close()
ifile2.close()
isHeader = True
for row2 in conTopic:
if isHeader:
row2.insert(-1,'favorite_count')
row2.insert(-1,'retweet_count')
writer.writerow(row2)
isHeader = False
else:
for row1 in conRetuitsFav[1:]:
if row1[0] == row2[0]:
row2.insert(-1,row1[-8])
row2.insert(-1,row1[-7])
writer.writerow(row2)
break
# Se cierran todos los archivos.
ofile.close()