I have seen a few questions on this topic but I wanted to check here for some clarification.
The basic problem is I have a script I am running it on a server and this line fails to run:
with open("Copy of normalized.log2.counts.csv") as bedR:
line = bedR.readline()
print(line.split(sep))
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range (128)
In this case sep = ","
. When I run the following (essentially same) commands locally I get a valid result:
with open("Copy of normalized.log2.counts.csv") as bedR:
line = bedR.readline()
#get start col
print(line.split(sep))
Since my PC is running Windows and the server is UNIX I suspect that there is some issue with translation.
*note I used dos2unix
on both files before running the script and this appears to work so far, but I would love a solution that involves global settings that I can str within my python script if possible, or methods to encode the whole file from python.