PDA

View Full Version : while loading a libreoffice text csv file in to jupyter notebook got errors



vincent727
January 19th, 2018, 03:51 PM
while loading a libreoffice text csv file to jupyter notebook using Pandas I got an IOError as below. I am not sure if text csv can be read like an excel csv file? If not, how to solve this problem since excel cannot be used in ubuntu???

Kindly help! thanks!




IOError: File root/home/vincent/Documents/ru000-180118.csv does not exist

ajgreeny
January 19th, 2018, 06:41 PM
As far as I'm aware a .csv file should be the same wherever it came from.
However I suspect that pathway (where did that come from?) root/home/vincent/Documents/ru000-180118.csv is the problem and should be corrected to /home/vincent/Documents/ru000-180118.csv.

PS:
What is Pandas and jupyter? The more detail you give us the more likely you are to get a useful answer.

vincent727
January 19th, 2018, 07:48 PM
As far as I'm aware a .csv file should be the same wherever it came from.
However I suspect that pathway (where did that come from?) root/home/vincent/Documents/ru000-180118.csv is the problem and should be corrected to /home/vincent/Documents/ru000-180118.csv.

PS:
What is Pandas and jupyter? The more detail you give us the more likely you are to get a useful answer.

pandas is an open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language.

Jupyter Notebook is an open-source web application that allows creating and sharing documents that contain live code, equations, visualizations and narrative text.


In the beginning I tried with /home/vincent/Documents/ru000-180118.csv but did not work. It showed pathway error. after I changed to root/home/vincent/Documents/ru000-180118.csv the error became IOError as shown in my first post. I will attach a full pic for reference.

vasa1
January 20th, 2018, 03:18 AM
What does
locate ru000-180118.csvshow you?

vincent727
January 20th, 2018, 03:47 AM
What does
locate ru000-180118.csvshow you?


vincent@vincent:~$ locate ru000-180118.csv
/home/vincent/.config/libreoffice/4/user/backup/ru000-180118.csv_0.ods
/home/vincent/.local/share/Trash/files/ru000-180118.csv
/home/vincent/.local/share/Trash/info/ru000-180118.csv.trashinfo
/home/vincent/Documents/.~lock.ru000-180118.csv#
/home/vincent/Documents/ru000-180118.csv
vincent@vincent:~$

SeijiSensei
January 20th, 2018, 05:55 AM
Try removing the lock file: /home/vincent/Documents/.~lock.ru000-180118.csv#

Any better?

Make sure you close all instances of LibreOffice before this.

vasa1
January 20th, 2018, 10:46 AM
Try removing the lock file: /home/vincent/Documents/.~lock.ru000-180118.csv#

Any better?

Make sure you close all instances of LibreOffice before this.
Normally, a lock file is created when a file is opened in LibreOffice. Once LibreOffice is closed, the lock file goes away.

vincent727
January 20th, 2018, 02:23 PM
Try removing the lock file: /home/vincent/Documents/.~lock.ru000-180118.csv#

Any better?

Make sure you close all instances of LibreOffice before this.

How can I find this lock file?
I tried to remove this file in Documents directory with code

rm .~lock.ru000-180118.csv# but created
rm: cannot remove '.~lock.ru000-180118.csv#': No such file or directory

vincent727
January 20th, 2018, 02:27 PM
Normally, a lock file is created when a file is opened in LibreOffice. Once LibreOffice is closed, the lock file goes away.


I already closed Libreoffice but don't understand why the lock file still exists.

vasa1
January 20th, 2018, 02:50 PM
Then, as SeijiSensei suggested, see if deleting it helps with your issue.

SeijiSensei
January 20th, 2018, 05:41 PM
How can I find this lock file?
I tried to remove this file in Documents directory with code

rm .~lock.ru000-180118.csv#

Run


ls -a /home/vincent/Documents

Is it still there? If so, try wrapping the file name in single quotes like this:


rm -f '/home/vincent/Documents/.~lock.ru000-180118.csv#'

The hash mark at the end has a special meaning in the bash shell; it denotes the beginning of a comment. Encasing the string in single quotes tells bash to treat the string literally and ignore any special meaning it might otherwise assign to the characters.

vincent727
January 21st, 2018, 02:47 AM
Run


ls -a /home/vincent/Documents

Is it still there? If so, try wrapping the file name in single quotes like this:


rm -f '/home/vincent/Documents/.~lock.ru000-180118.csv#'

The hash mark at the end has a special meaning in the bash shell; it denotes the beginning of a comment. Encasing the string in single quotes tells bash to treat the string literally and ignore any special meaning it might otherwise assign to the characters.

After running
ls -a /home/vincent/Documents , file .~lock.ru000-180118.csv# is no longer there in the directory. I re-run the
locate .ru000-180118.csv and got below outcome.
/home/vincent/Documents/ru000-180118.csv

That is to say, the lock file already disappears.

I tried running the codes again in Jupyter Notebook:

import pandas as pd

ru000 = pd.read_csv("home/vincent/Documents/ru000-180118.csv")

I still got the same error:

IOError: File home/vincent/Documents/ru000-180118.csv does not exist

spjackson
January 21st, 2018, 03:06 PM
home/vincent/Documents/ru000-180118.csv is not /home/vincent/Documents/ru000-180118.csv. Try


ru000 = pd.read_csv("/home/vincent/Documents/ru000-180118.csv")

vincent727
January 21st, 2018, 09:27 PM
home/vincent/Documents/ru000-180118.csv is not /home/vincent/Documents/ru000-180118.csv. Try


ru000 = pd.read_csv("/home/vincent/Documents/ru000-180118.csv")


It worked!
Thanks you very much, Spjackson! I am still new to ubuntu and sometime it is a little confusing to me for even simple small issue.

BTW, thank all guys who have helped me with this issue.

vincent727
January 22nd, 2018, 02:40 AM
Well, I tried pandas reading other several .csv files into jupyter notebook and got exactly the same error!
Checked again and again and I am sure the path is correct, the files are surely there in the designated folder......

It seems ubuntu is not as friendly in handling .csv spreadsheet with pandas as Windows system. I looked up in the web but could not find a solution for this. Wondering if there is an alternative way to import the .csv spreadsheet with pandas in ubuntu?