[Tutor] Extract Field from List

Lucas Cavalcante lucas at labcodes.com.br
Sun Aug 8 10:02:55 EDT 2021


Hey Stephan,

It is not quite clear what is the desired output you expect to obtain.
Can you draft how would you like the output to be from this example you
shared?

Kind regards,
Lucas C

Em dom, 8 de ago de 2021 16:49, Stephen P. Molnar <s.molnar at sbcglobal.net>
escreveu:

> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list