[Tutor] Extract Field from List
Stephen P. Molnar
s.molnar at sbcglobal.net
Sun Aug 8 09:48:00 EDT 2021
I have hit a roadblock in a Python script I have been developing to
process a large number of text files of fixed format.
I have a list of names of chemicals, which I can read into a list.csv:
CaffeicAcid,Cannflavin-A,Cannflavin-B,Cannflavin-C,Diosmetin,Echinacoside,Hesperetin,L-CichoricAcid
My code is;
import csv
with open("Ligand.list_r.txt", newline='') as csvfile:
rows = csv.reader(csvfile, delimiter = ',')
data = []
for rows in rows:
data.append(rows)
print(data)
This results in:
[['CaffeicAcid\tCannflavin-A\tCannflavin-B\tCannflavin-C\tDiosmetin\tEchinacoside\tHesperetin\tL-CichoricAcid']]
when run.
What I need to do is iterate through the list and generate names of the
format of chemicalname+'.i.log'.
This is where I can seem to hit a show stopper. How do I extract fields
form the list generated by the script that works? What am I missing?
--
Stephen P. Molnar, Ph.D.
614.312.7528 (c)
Skype: smolnar1
More information about the Tutor
mailing list