0

I have a list created after perforing basic filter in a WHILE loop. now I want each of my list ros in a single DataFrame That I can access outside the loop.

the code I have is

filePath = "pinToBall_Bump.csv"

with open(filePath, 'r') as inpFile:
    line = inpFile.readline()
    while line:
        # print(line)
        filter1 = re.sub(r'^[io_]+', "", line)
        filter2 = re.sub(r'^[gddr6_]+', "", filter1)
        filterList = filter2.split(",")
        print(filterList)
        line = inpFile.readline()
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • FYI you can write `for line in inpFile:` to loop over the lines, instead of calling `readline()` twice and testing it. – Barmar Apr 05 '21 at 06:24
  • now my code looks like with open(filePath, 'r') as inpFile: for line in inpFile: # print(line) filter1 = re.sub(r'^[io_]+', "", line) filter2 = re.sub(r'^[gddr6_]+', "", filter1) allUpper = filter2.upper() print(allUpper) how can I now get the allUpper string type in a single dataframe which I can access as a whole set outside of the for loop – nikhil jha Apr 05 '21 at 06:41
  • See the question I linked to above. It shows how to add a list as a row to a pandas dataframe. – Barmar Apr 05 '21 at 06:48

0 Answers0