Languages :: PHP :: preserve newline and whitespace |
|||
| By: phpsnook |
Date: 25/09/2008 15:11:36 |
Points: 20 | Status: Answered Quality : Excellent |
|
how to preserve newline and whitespace characters while converting excel to mysql pls help! |
|||
| By: VGR | Date: 25/09/2008 17:10:28 | Type : Comment |
|
| hummm your question is not very clear ;-) if you "convert from excel to mysql", it probably means you "export as a CSV file". In this case, there are only one couple of CR+LF (or LF alone, or CR alone) as end-of-line, per line. So : I probably don't get your question right. Could you be more explicit ? Do you have eXcel data with newlines in it ? (how strange ;-) From my personal experience, I know that the eventual whitespaces and newlines IN THE DATA (eXcel cells) are preserved, and the whole value put between normal CSV quotes (double quotes " ) This can cause problems when reading the CSV file back, depending on how you perform the command (LOAD DATA INFILE or console input redirect or other). |
|||
| By: phpsnook | Date: 26/09/2008 07:07:05 | Type : Answer |
|
| in my excel file the is a column for addresss the data is of this format 124 Texas Center Drive San Diego, CA 92121, USA, Tel:+1-858 458-789. but when i convert it into a mysql query it is like this 4757 Nexus Center Drive San Diego, CA 92121, USA Tel:+1-858 458-4500 i want the new line character to be preserved so that the same address format of: 124 Texas Center Drive San Diego, CA 92121, USA, Tel:+1-858 458-789. is maintained when i export from mysql to excel format..... |
|||
| By: phpsnook | Date: 26/09/2008 10:46:31 | Type : Comment |
|
| hey i guess i fixed it preg_replace ('#\r?\n#','\r\n',$str); |
|||
| By: VGR | Date: 26/09/2008 20:07:18 | Type : Comment |
|
| well, if you rely already on regular expresisons (very sloooowww and unmaintainable) for such a problem, good luck for the future ;-)) I still haven't understood WHERE you were standing, HOW you exported your data and HOW you were importing it. Whatever... |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








