Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud9 Mysql importing .tsv into table

Tags:

import

mysql

csv

I have sports watch data which measures heart rate, calories, strides taken etc.

I have created a database and table in cloud9 and was wondering if there is a way to import the .tsv data. I also have a copy of the raw data as .txt saved on cloud9 if that is easier to work with?

I am new with sql and its my 1st year in university could use some help with this as I don't understand a method on how to do it.

LOAD DATA INFILE 'all_project_database/MeanMachine/data/data_all.tsv' INTO TABLE Patients;

ERROR 13 (HY000): Can't get stat of '/var/lib/mysql/all_project_database/MeanMachine/data/data_all.tsv' (Errcode: 2)

any help is much appreciated, thank you in advance.

like image 915
jamesonr Avatar asked Oct 23 '25 15:10

jamesonr


2 Answers

MySQL has a command LOAD DATA INFILE:

https://dev.mysql.com/doc/refman/5.5/en/loading-tables.html

It should be able to solve your problem.

UPDATE: to correct the error, you need a slash in your file path:

LOAD DATA INFILE '/all_project_database/MeanMachine/data/data_all.tsv' INTO TABLE Patients;

assuming you do have a file at that location. To check if you do:

ls -l /all_project_database/MeanMachine/data/data_all.tsv
like image 132
Sasha Pachev Avatar answered Oct 26 '25 05:10

Sasha Pachev


I moved the .tsv file into the mysql directory and it the code worked! Thanks for help

like image 44
jamesonr Avatar answered Oct 26 '25 06:10

jamesonr