I've attempted several times to load my data from my file into my database, but when the statements run they load 0 data.
My data has 8k rows that look like this file image; and my load data statement:
LOAD DATA INFILE '/home/codio/workspace/FleetMaintenanceRecords.csv'
INTO TABLE parts_maintenance
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\\r\\n'
IGNORE 1 LINES;
But when I run it nothing loads, and when I try without the termination lines I get the following error:
ERROR 1265 (01000): Data truncated for column 'VehicleID' at row 1
or this:
ERROR 1366 (HY000): Incorrect integer value: 'VehicleID,State,Repair,Reason,YEAR,Make,BodyType' for column 'VehicleID' at row 1
The table I'm loading into looks like this:
describe parts_maintenance;
\+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
\+-----------+--------------+------+-----+---------+-------+
| VehicleID | bigint | YES | | NULL | |
| State | varchar(4) | YES | | NULL | |
| Repair | varchar(255) | YES | | NULL | |
| Reason | varchar(255) | YES | | NULL | |
| YEAR | int | YES | | NULL | |
| Make | varchar(50) | YES | | NULL | |
| BodyType | varchar(255) | YES | | NULL | |
\+-----------+--------------+------+-----+---------+-------+
What am I doing wrong? I've reached out to my professor, tutors, etc. and no one seems to be able to help!
- Removing the terminated statements
- Updating the csv file in excel and notepad++ to ensure the format matches
- Changed column headers and integer types
- Contacted my professor and the online tutors
- Revised column 1 to ensure they are only numeric values
There are missing “'” at first and second data line besides extra “,” at the end of first to fourth lines.