Reputation: 373
I'm using MySQL with php. Through a php script i'm trying to import a csv file with the following query
LOAD DATA LOCAL INFILE '$file'
INTO TABLE userstable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n' IGNORE 1 LINES (name, univ, mobile);
I'm successfully able to import the file in to the database tables but i'm able to see hidden formatting symbols (as in word, powerpoint, etc..) in all the cells under the last column i.e mobile.
How to avoid those from inserting in the table
Upvotes: 4
Views: 644
Reputation: 161
Could be DOS line endings. Try it with
LINES TERMINATED BY '\r\n'
instead.
Upvotes: 1
Reputation: 3205
I think you're going to have to use regular expressions to filter the data before it is saved. If I remember correctly, most of that formatting is standardized, so it should be easy to find and eliminate before adding it to your dB. - lee
Upvotes: 0