Cov = pd.read_csv("path/to/file.txt", sep='\t') Frame=pd.DataFrame(Cov.values, columns = ["Sequence", "Start", "End", "Coverage"]) Frame.to_csv("path/to/file.txt", sep='\t')
Here is what the above code is Doing:
1. Reads in the file as a tab-delimited file
2. Creates a dataframe from the file
3. Writes the dataframe to a tab-delimited file
You can also use the following code to read in a tab-delimited file:
Cov = pd.read_csv(“path/to/file.txt”, sep=’\t’)
This will read in the file as a tab-delimited file and create a dataframe from it.