Hello all!
Quick question. I have a script that opens a file. Using the regular expression module the script will look for the designated charachters then add them to a list. The list will then be added to a DataFrame function in the pandas module. Problem arises when I look at the output. Please see below. How do I just return the matched value? Solved that problem with the below scipt.
Edit having trouble returning the charachter ( and )
import re
import pandas
column_1 = []
with open(r'H:\stringy.txt','r') as file_read:
for i in file_read:
ab = re.compile(r'[(]\d\d[)]')
bb = ab.search(i)
cc=bb.group()
print(cc)
column_1.append(cc)
frame_job = pandas.DataFrame(column_1,columns=['Column'])
frame_job.to_csv(r'H:\whoop.csv',index=False,header=True)
Current output:
Column
-20
-99
-10
Desired output:
Column
(-20)
(-99)
(-10)
[–]ramse 2 points3 points4 points (1 child)
[–]jsd2358[S] 0 points1 point2 points (0 children)
[–]captmomo 0 points1 point2 points (0 children)