Hrasha

Hrasha

  • NA
  • 103
  • 6.3k

Please help how can I add (molecule_name) in dataframe

Apr 4 2021 10:23 AM
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)

Answers (2)