-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
49 lines (48 loc) · 1.35 KB
/
main.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
47
48
49
import pandas as pd
import glob,os,re
#You enter the path of the file
path = '.'
extension = 'csv'
#os.chdir(path)
result = glob.glob('*.{}'.format(extension))
count = 1
for res in result:
print(count,". ",res)
count += 1
print("please choose the correct no")
fileInput=input("Enter file no:")
data = pd.read_csv(result[int(fileInput) - 1])
#print(data)
print(type(data))
tu = data.values.tolist()
print(tu[:5])
#tu = input("this")
l=[]
for u in tu:
temp = []
g = u[1]
g = g.upper()
temp.append(g)
w = u[0]
w = w.lower()
temp.append(w)
if(g == "BID"):
temp.append(u[2])
temp.append(u[3])
l.append(temp)
#Here you choose how many names you want for the output files
number=input("How many names you want in a single file :")
#You enter the neame of the output files, if you forgot to add the extension the program will add .txt
#nameOfFile=input("enter the name of the output file:")
nameOfFile = "output"
if nameOfFile.endswith(".txt")==0:
nameOfFile+=".txt"
z=0
#if you have more than one files we iterate it's names
for i in range (0,len(l),int(number)):
f=open(nameOfFile.split(".")[0]+str(z)+"."+nameOfFile.split(".")[1],"w")
jk = str(l[i:i+int(number)])
jk = re.sub("\'",'"',jk)
f.write("hsw-rpc sendbatch '" + jk + "'")
f.close()
z+=1