visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: preserve newline and whitespace


By: phpsnook India  Date: 25/09/2008 15:11:36  English  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 English  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 English  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 English  Type : Comment
hey i guess i fixed it

preg_replace ('#\r?\n#','\r\n',$str);


By: VGR Date: 26/09/2008 20:07:18 English  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

EContact
browser fav
page generated in 100.512980 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page