-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeparate_Tweet.py
More file actions
26 lines (25 loc) · 1011 Bytes
/
Separate_Tweet.py
File metadata and controls
26 lines (25 loc) · 1011 Bytes
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
import csv
out = open('sample_1.csv', 'w')
for y in range(1,6):
with open('sample.csv', 'r', encoding="utf-8") as f:
content = csv.reader(f)
counter = 0
z_counter = 0
for x in content: # retrieve all row info within results
print(counter)
counter += 1
# print(len(x))
for z in range(len(x)): # loop within row for column info
# print(z)
z_counter += 1
if z == 0: # split tweet from user ID / date
out.write(x[z].split()[0])
out.write(',')
elif z == 93: # reached end of info, make new line
out.write(x[z])
out.write('\n')
else: # all data in the middle
out.write(x[z])
out.write(',')
z_counter = 0 # reset column counter so it doesn't continue to increase and go out of index
out.close()