1
cut2=(
('Shared',Signature_1, 'and',Signature_2, 'and',Signature_3,str(shared_A_B_C))
lines2 = '\n'.join([' '.join(i) + '\n' for i in cut2])
f2.write(lines2)
f2.close()

output=Shared V.txt and 5T.txt and 3T.txt {'Ccdc92', 'Esam', 'Apoc1', 'Sec14l2', 'Ces1c', 'Hsd11b1',...}

What are some potential and practical approaches to generating a .txt file with set data listed in a column format? Currently I can write my set data to a .txt file by converting them to strings this produces a list that is read left to right. I would like to alter the formatting so the organization is by column. I have successfully read from .txt files with columns and generated lists and dictionaries but never the reverse. Any advice on how best to accomplish would be appreciated. Thank you in advance.

dkh32
  • 63
  • 7
  • 3
    check out https://stackoverflow.com/help/minimal-reproducible-example , i.e. make a smaller example , just as big as necessary . This makes it easier for people to help. – roadrunner66 Sep 22 '20 at 21:51
  • 1
    Sorting by column requires the data to be in a matrix or tabular format, where you can transpose. That would suggest using numpy (better for numerical data than yours) or pandas. Also check out the `zip` command, and transpose a list of lists https://stackoverflow.com/questions/6473679/transpose-list-of-lists – roadrunner66 Sep 22 '20 at 21:55
  • 1
    Everybody seems to be using Pandas these days. So many, that it must be something that's pretty easy to get to know and use. I would suggest finding a good tutorial or book on it. I haven 't done much with it myself, but my guess is that it has the capability either by itself, or with just a few lines of generic Python added, to write data to a file in just about any imaginable format. It's will definitely have no problem representing and manipulating your data in memory, as that's what it was built for. – CryptoFool Sep 22 '20 at 23:59

0 Answers0