I have a question for beginner Python students.

Asked 2 years ago, Updated 2 years ago, 35 views

If you look at the data below, I want to include the #CHROM line so that the data below can come out in Excel format, but it keeps coming out in one line... Is there any way? Desired result is below

Change the picture above to the way below.

It's very easy, but I don't know because I'm a beginner. Help me...

I'll post what I planned just in case you need it.

f = open("test.vcf", 'r')
fw= open("result.txt", 'w')

file_a = f.readlines()
for i in file_a:
    part = file_a[280:]
    part1= str(part)
    part2= part1.split("\\")
    print part2
    print >> fw,part2
    break
f.close()
fw.close()

python

2022-09-21 21:30

1 Answers

If you are a csv file with a description in the front of the file, you can read the data by skipping the annotation part, not the data, by giving the skiprows option, while reading it as a read_csv function in pandas.


2022-09-21 21:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.