Please help how can I add (molecule_name) in dataframe
import glob
import pandas as pd
filenames = glob.glob(file_location) print(filenames)
first_file = filenames[0]
print(first_file)
file_name = os.path.basename(first_file)
print(file_name)
for f in filenames:
# Get the molecule name
file_name = os.path.basename(f)
split_filname = file_name.split('.')
molecule_name = split_filename[0]
# Read the data
outfile = open(f,'r')
data = outfile.readlines()
outfile.close()
print(molecule_name)
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Rajanikant HawaldarRank #110 · 20.2K reputationPosted Apr 4, 2021, 6:38 AM EDT
Hrasha91 reputationPosted Apr 4, 2021, 6:54 AM EDT