'How to open a .tsv file in Jupyter? Jupyter.Notebook tried suggestions, but it doesn't work
How can I open a .tsv
file in Jupyter.
The data is stored under C:/User/anna/
.
This is my code:
import pandas as pd
df=pd.read_csv('C:/User/anna/train')
But I get this error message:
FileNotFoundError: File b'C:/Users/anna/train.txt' does not exist
Solution 1:[1]
it's actually to do with pandas, by default the separator is comma, not tab. try the code below:
df=pd.read_csv('C:/User/anna/train', sep='\t')
Solution 2:[2]
it sounds lame, but finally i opened it - my first attempt to open anything in anaconda.: )
thanks.
df=pd.read_csv('C:/User/anna/train.tsv',sep='\t')
Solution 3:[3]
If you're opening .tsv file from your local, please attempt the below code:
import pandas as pd
df=pd.csv_read(r'c:\User\anna\train.tsv', sep='\t')
print(df)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | HappyBambi |
Solution 2 | WJ Zhao |
Solution 3 |