forked from scriptik/vougen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsc2csv.py
35 lines (32 loc) · 978 Bytes
/
rsc2csv.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
#### Convert the (vougen)rsc File to csv
#### PEZHMAN SHAFIGH 2019
import os
import re
import csv
import datetime
file_in = 'users.rsc'
file_ou = 'users.csv'
num_lines = sum(1 for line in open(file_in))
with open(file_in) as file_object:
string = ''
for line in file_object:
string += line.rstrip() +"\n"
#print(num_lines)
num_id = num_lines-1
num_id = num_lines-1
lni = num_id*5 #last name id
words = (string.split())
#print(len(words))
with open(file_ou, 'w') as file_out:
file_out.write("Name,Password,Server,UpTime\n")
start = '='
end = ','
for i in range (5,lni,5):
name = ((words[i].split(start))[1].split(end)[0])
password = ((words[i+1].split(start))[1].split(end)[0])
server = ((words[i+2].split(start))[1].split(end)[0])
litime = ((words[i-1].split(start))[1].split(end)[0])
instr = (name+","+password+","+server+","+litime)
#print(instr)
with open(file_ou, 'a') as file_out:
file_out.write(instr+"\n")