mport csv files to Mysql with \r\n data

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

mport csv files to Mysql with \r\n data

Post by kendall »

Hello,

I am developing a restore/ update tables in a mysql database using data uploaded from a comma delimited format.

My question arises when i get errors pertaining to inserting the data back into mysql using mysql_query() because of "line breaks" in the data. i have tried converting these line breaks into their ascii character but i still get the error for it.

Can you guys recommend a method in dealing with a situation such as this?

Kendall
P.S. do you knwo of any snippet code librarys that allow me to parse the csv files based on its csv options i.e. fields terminated by, fields enclosed in, lines terminated by....etc
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

nl2br might be what you are looking for.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

import csv files to Mysql with \r\n data

Post by kendall »

infolock,

I was trying that but it is so hard to determine wether the new line is part of the data or an actual new row

Kendall
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

this thread may be of interest.
Post Reply